The classifier

Before we continue to build our classifier, let's imagine what the main function will look as follows. It will look something similar to this:

unc main() {  examples, err := ingest("bare")  log.Printf("Examples loaded: %d, Errors: %v", len(examples), err)  shuffle(examples)  if len(examples) == 0 {    log.Fatal("Cannot proceed: no training examples")  }  // create new classifier  c := New()  // train new classifier  c.Train(examples)  // predict  predicted := c.Predict(aDocument)  fmt.Printf("Predicted %v", predicted)}

The use of Train and Predict as exported methods are useful in guiding us on what to build next. From the sketch in the preceding code block, we need a Classifier type, that has Train and Predict at the very least. So we'll ...

Get Go Machine Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.