bayesian

package
v0.0.0-...-be156a4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class string

Class is alias of string, representing class of a document

type Classifier

type Classifier struct {
	Model              Model
	LearningResults    map[string]map[Class]int
	PriorProbabilities map[Class]float64
	NDocumentByClass   map[Class]int
	NFrequencyByClass  map[Class]int
	NAllDocument       int
}

Classifier is object for classifying document

func NewClassifier

func NewClassifier(model Model) Classifier

NewClassifier returns new Classifier

func NewClassifierFromFile

func NewClassifierFromFile(path string) (Classifier, error)

NewClassifierFromFile returns new Classifier with configuration loaded from file in path

func (Classifier) Classify

func (classifier Classifier) Classify(tokens []string) (map[Class]float64, Class, bool)

Classify executes classifying process for tokens

func (*Classifier) Learn

func (classifier *Classifier) Learn(docs ...Document)

Learn executes learning process for this classifier

func (Classifier) SaveClassifierToFile

func (classifier Classifier) SaveClassifierToFile(path string) error

SaveClassifierToFile saves Classifier config to file in path

type Document

type Document struct {
	Class  Class
	Tokens []string
}

Document is a group of tokens with certain class

func NewDocument

func NewDocument(class Class, tokens []string) Document

NewDocument return new Document func NewDocument(class Class, tokens ...string) Document {

type Model

type Model int

Model is alias of int, representing Naive-Bayes model that used in classifier

const (
	// MultinomialTf is model where frequency of token affects posterior probability
	MultinomialTf Model = 1

	// MultinomialBoolean is model like TF, but each token only calculated once for each document
	MultinomialBoolean Model = 2
)

Jump to

Keyboard shortcuts

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