clf

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfusionMatrix added in v0.9.0

func GetConfusionMatrix(classifConfig *Config) (confusionMatrix [][]int, yTrue, yPred []int)

func GetSums added in v0.9.0

func GetSums(confusionMatrix [][]int) (sumI, sumJ []int, sumIJ, sumTrue int)

Types

type Classifier

type Classifier struct {
	Model    Model
	Pipeline *pipeline.Config
}

Classifier models a classifier and its classes

func New

func New(config *Config) *Classifier

New returns a trained Classifier

type Config

type Config struct {
	Classification dataset.DataSet `yaml:"classification"`
	Pipeline       pipeline.Config `yaml:"pipeline"`
	Model          ModelConfig     `yaml:"model"`
}

Config models a classification yaml file

func LoadConfig

func LoadConfig(path string, reloadChan chan Config) (*Config, error)

LoadConfig loads classification configuration from yaml

type Model added in v0.8.1

type Model interface {
	// Learn takes a training dataset as input and trains the model
	// It returns the training accuracy for the model
	Learn(texts dataset.DataSet, pipe *pipeline.Config) float32

	// Predict makes a class prediction based on the trained model
	Predict(text string, pipe *pipeline.Config) (predictedClass string, proba float32)

	// Save persists the model to a file
	Save(directory string) error
}

Model interface contains the basic functions for a model to have

type ModelConfig added in v0.8.1

type ModelConfig struct {
	// Classifier is the type of classifier to be used
	Classifier string `mapstructure:"classifier"`

	// Parameters holds any other model parameters
	// TODO: improve this field
	Parameters map[string]interface{} `mapstructure:"parameters"`

	// Directory is the path to the saved model files
	Directory string `mapstructure:"directory"`

	// Whether to save the trained model or not
	Save bool `mapstructure:"save"`

	// Whether to load the saved model or not
	Load bool `mapstructure:"load"`

	// WordVectorsConfig contains configuration for fasttext word vectors
	WordVectorsConfig wordvectors.Config `mapstructure:"word_vectors"`
}

ModelConfig defines the data for the model's operation

type Scores added in v0.9.0

type Scores struct {
	Precision []float64
	Recall    []float64
	F1score   []float64

	PrecisionAvg float64
	RecallAvg    float64
	F1scoreAvg   float64

	PrecisionWeightedAvg float64
	RecallWeightedAvg    float64
	F1scoreWeightedAvg   float64

	Accuracy float64
}

func GetScores added in v0.9.0

func GetScores(confusionMatrix [][]int, sumI, sumJ []int, sumIJ, sumTrue int) (s Scores)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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