naive_bayes

package
v0.0.0-...-742bdff Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NaiveBayesClassifier

type NaiveBayesClassifier struct {
	Words               map[string]map[string]int
	TotalWords          int
	CategoriesDocuments map[string]int
	TotalDocuments      int
	CategoriesWords     map[string]int
	Threshold           float64
}

NaiveBayesClassifier is what we use to classify documents

func New

func New(threshold float64) *NaiveBayesClassifier

create and initialize the classifier

func NewClassifierFromFile

func NewClassifierFromFile(path string) (*NaiveBayesClassifier, error)

create and initialize the classifier from a file

func NewClassifierFromFileData

func NewClassifierFromFileData(data []byte) (*NaiveBayesClassifier, error)

create and initialize the classifier from a file data

func NewClassifierWithReader

func NewClassifierWithReader(reader io.Reader) (*NaiveBayesClassifier, error)

create and initialize the classifier from a file data

func (*NaiveBayesClassifier) Classify

func (c *NaiveBayesClassifier) Classify(document string) (category string)

Classify a document

func (*NaiveBayesClassifier) Evaluate

func (c *NaiveBayesClassifier) Evaluate(train, test []mlutils.LabeledDocument)

func (*NaiveBayesClassifier) Fit

func (c *NaiveBayesClassifier) Fit(data map[string][]string)

func (*NaiveBayesClassifier) Probabilities

func (c *NaiveBayesClassifier) Probabilities(document string) (p map[string]float64)

Probabilities of each category

func (*NaiveBayesClassifier) SaveClassifierToFile

func (c *NaiveBayesClassifier) SaveClassifierToFile(path string) error

save the classifier to a file

type Sorted

type Sorted struct {
	Category    string
	Probability float64
}

Jump to

Keyboard shortcuts

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