jbrukh / bayesian

Naive Bayesian Classification for Golang.
Other
805 stars 128 forks source link

Seen() is always 0? #19

Open uccmen opened 7 years ago

uccmen commented 7 years ago
package main

import (
    "log"

    "github.com/jbrukh/bayesian"
)

const (
    Arabic  bayesian.Class = "Arabic"
    Malay   bayesian.Class = "Malay"
    Yiddish bayesian.Class = "Yiddish"
)

func main() {

    nbClassifier := bayesian.NewClassifier(Arabic, Malay, Yiddish)
    arabicStuff := []string{"algeria", "bahrain", "comoros"}
    malaysianStuff := []string{"malaysians", "bahasa"}
    yiddishStuff := []string{"jewish", "jews", "israel"}
    nbClassifier.Learn(arabicStuff, Arabic)
    nbClassifier.Learn(malaysianStuff, Malay)
    nbClassifier.Learn(yiddishStuff, Yiddish)

    log.Println(nbClassifier.Learned()) // 3
    log.Printf(`SEEN: %d`, nbClassifier.Seen()) // 0
}
navossoc commented 7 years ago

Probably you already figured it out, but...

Seen() will increase only after you call one of the following methods:

nbClassifier.LogScores(...)
nbClassifier.ProbScores(...)
nbClassifier.SafeProbScores(...)