Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EuclideanDistance ¶
EuclideanDistance calculates euclidean distance between two points
Types ¶
type Classifier ¶
type Classifier struct { KNN *KNN VectorMap *wordvectors.VectorMap K int }
Classifier is a K-Nearest Neighbors classifier
func Load ¶
func Load(directory string) (classifier *Classifier, err error)
func NewClassifier ¶
func NewClassifier(wordVecConfig wordvectors.Config, params map[string]interface{}) *Classifier
NewClassifier creates a KNN classifier with truncate and file data
func NewClassifierFromFile ¶
func NewClassifierFromFile(name string) (*Classifier, error)
func (*Classifier) Learn ¶
Learn takes the training texts and trains the K-Nearest Neighbors classifier
func (*Classifier) Predict ¶
func (c *Classifier) Predict(text string, pipe *pipeline.Config) (predictedClass string, proba float32)
Predict predict a class for a given text
func (*Classifier) Save ¶
func (c *Classifier) Save(directory string) error
Save persists the model to a file
func (*Classifier) SaveToFile ¶
func (c *Classifier) SaveToFile(name string) error
type KNN ¶
KNN main structure
func (*KNN) PredictMany ¶
PredictMany performs a classification on multiple input vectors
func (*KNN) PredictOne ¶
PredictOne performs a classification on one input vector
func (*KNN) SaveToFile ¶
type Parameters ¶
type Parameters struct {
K int `mapstructure:"k"`
}
Parameters represents the model hyperparameters
Click to show internal directories.
Click to hide internal directories.