clf

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: MIT Imports: 10 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    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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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