Versions in this module Expand all Collapse all v1 v1.0.0 Aug 5, 2026 Changes in this version + var ErrAlreadyConverted = errors.New("cannot add class after TF-IDF conversion") + var ErrClassExists = errors.New("class already exists") + var ErrUnderflow = errors.New("possible underflow detected") + func RegisterClassificationPreload(v *vm.VM) + type Class string + type Classifier struct + Classes []Class + DidConvertTfIdf bool + func NewClassifier(classes ...Class) *Classifier + func NewClassifierFromFile(name string) (*Classifier, error) + func NewClassifierFromReader(r io.Reader) (*Classifier, error) + func NewClassifierTfIdf(classes ...Class) *Classifier + func (c *Classifier) AddClass(class Class) error + func (c *Classifier) Classify(document []string) (Class, []float64, bool) + func (c *Classifier) ClassifyProb(document []string) (Class, []float64, bool) + func (c *Classifier) ClassifySafe(document []string) (Class, []float64, bool, error) + func (c *Classifier) ConvertTermsFreqToTfIdf() + func (c *Classifier) IsTfIdf() bool + func (c *Classifier) Learn(document []string, which Class) + func (c *Classifier) Learned() int + func (c *Classifier) LogScores(document []string) ([]float64, int, bool) + func (c *Classifier) Observe(word string, count int, which Class) + func (c *Classifier) ProbScores(doc []string) ([]float64, int, bool) + func (c *Classifier) ReadClassFromFile(class Class, location string) (err error) + func (c *Classifier) SafeProbScores(doc []string) ([]float64, int, bool, error) + func (c *Classifier) Seen() int + func (c *Classifier) WordCount() []int + func (c *Classifier) WordFrequencies(words []string) [][]float64 + func (c *Classifier) WordsByClass(class Class) (freqMap map[string]float64) + func (c *Classifier) WriteClassToFile(name Class, rootPath string) error + func (c *Classifier) WriteClassesToFile(rootPath string) error + func (c *Classifier) WriteGob(w io.Writer) (err error) + func (c *Classifier) WriteToFile(name string) error + type KNN struct + func NewKNN(k int) *KNN + func (m *KNN) Fit(features [][]float64, labels []string) + func (m *KNN) Predict(x []float64) string + type LogisticRegression struct + func NewLogisticRegression(lr float64, epochs int) *LogisticRegression + func (m *LogisticRegression) Fit(features [][]float64, labels []string) + func (m *LogisticRegression) Predict(x []float64) string + func (m *LogisticRegression) PredictProba(x []float64) float64 + type Perceptron struct + func NewPerceptron(lr float64, epochs int) *Perceptron + func (p *Perceptron) Fit(features [][]float64, labels []string) + func (p *Perceptron) Predict(x []float64) string + type SVM struct + func NewSVM(cfg SVMConfig) *SVM + func (s *SVM) DecisionFunction(x []float64) float64 + func (s *SVM) Fit(features [][]float64, labels []string) + func (s *SVM) Predict(x []float64) string + func (s *SVM) SupportVectorCount() int + type SVMConfig struct + C float64 + Coef0 float64 + Degree int + Gamma float64 + Kernel SVMKernel + MaxIter int + Seed int64 + Tol float64 + type SVMKernel int + const KernelLinear + const KernelPoly + const KernelRBF + func ParseKernel(s string) SVMKernel Other modules containing this package github.com/hilthontt/luascript/v3