naivebayes

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Classifier

type Classifier struct {
	Model   *bayesian.Classifier
	Classes []bayesian.Class
	TfIdf   bool
}

Classifier is a Naïve-Bayes classifier

func Load

func Load(directory string) (classifier *Classifier, err error)

func NewClassifier

func NewClassifier(params map[string]interface{}) *Classifier

NewClassifier creates a Naive Bayes classifier with file data

func NewClassifierFromFile

func NewClassifierFromFile(name string) (*Classifier, error)

func (*Classifier) Learn

func (c *Classifier) Learn(texts dataset.DataSet, pipe *pipeline.Config) float32

Learn takes the training texts and trains the Naive-Bayes classifier

func (*Classifier) Predict

func (c *Classifier) Predict(text string, pipe *pipeline.Config) (predictedClass string, proba float32)

Predict predict a class for a given text

func (*Classifier) Save

func (c *Classifier) Save(directory string) error

Save persists the model to a file

func (*Classifier) SaveToFile

func (c *Classifier) SaveToFile(name string) error

type Parameters

type Parameters struct {
	TfIdf bool `mapstructure:"tfidf"`
}

Parameters represents the model hyperparameters

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL