Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class string
Class defines a class that the classifier will filter: C = {C_1, ..., C_n}. You should define your classes as a set of constants, for example as follows:
const ( Good Class = "Good" Bad Class = "Bad )
Class values should be unique.
type Classifier ¶
Classifier implements the Naive Bayesian Classifier.
func NewClassifier ¶
func NewClassifier(classes ...Class) (*Classifier, error)
NewClassifier returns a new classifier. The classes provided should be at least 2 in number and unique.
func NewClassifierFromFile ¶
func NewClassifierFromFile(name string) (c *Classifier, err error)
NewClassifierFromFile loads an existing classifier from file. The classifier was previously saved with a call to c.WriteToFile(string).
func NewClassifierFromReader ¶
func NewClassifierFromReader(r io.Reader) (c *Classifier, err error)
NewClassifierFromReader deserializes of a Gob encoded classifier.
func (*Classifier) Learn ¶
func (c *Classifier) Learn(document []string, class Class)
Learn supervised learns the given document.
func (*Classifier) ProbScores ¶
func (c *Classifier) ProbScores(doc []string) map[Class]float64
ProbScores calculates probabilities.
func (*Classifier) Write ¶
func (c *Classifier) Write(w io.Writer) (err error)
WriteTo serializes this classifier to GOB and write to Writer.
func (*Classifier) WriteToFile ¶
func (c *Classifier) WriteToFile(name string) (err error)
WriteToFile serializes this classifier to a file.