Naive Bayes implementation

I wrote a small Naive Bayes implementation in Go but I’m not 100% happy with how it is structured.

Is there a better way to structure the package? (Apart from moving everything to own functions).

Is there maybe a way to save priors in a file so that I don’t have to calculate them over and over
again when I run the function? This way I could save everything and just load it as soon as I want to
classify a new sentence.


I would start by thinking about to interact with a classifier. I don’t know much about classifiers, but my quick research and looking at your code suggests something like:

type Classifier interface {
    Train(class, sentence string)
    Classify(sentence string) (class string, p float64)

Then build a type that implements that interface.

Once you have a type, write Load and Save functions to deal with the serialization.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.