Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Match ¶
Match returns true if the Datum' are the same, otherwise false.
An error is returned if the Datum' have different lengths.
Types ¶
type Datum ¶
type Datum []float64
Datum is an array of floating point values, used as the input to a ML model.
func InitializeKMeans ¶
InitializeKMeans implements the init step for KMeans++ (at least,
it implements whatever this GeeksForGeeks article says: https://www.geeksforgeeks.org/ml-k-means-algorithm/)
type KNNClassifier ¶
KNNClassifier defines a KNN model for classifying input against known
samples. All training data is saved in the model, so be wary of size and performance for large training sets.
func LoadKNNClassifier ¶
func LoadKNNClassifier(path string) (*KNNClassifier, error)
LoadKNNClassifier is a convenience method for loading a save KNNClassifier model.
func NewKNNClassifier ¶
func NewKNNClassifier(k uint) *KNNClassifier
NewKNNClassifier constructs an untrained KNNClassifier.
func (*KNNClassifier) Fit ¶
func (kc *KNNClassifier) Fit(samples []Sample) error
Fit trains a KNNClassifier using given Samples.
func (*KNNClassifier) Predict ¶
func (kc *KNNClassifier) Predict(input []Datum) ([]Datum, error)
Predict finds the "closest" known Sample for each given Datum, and returns
the associated Sample output.
func (*KNNClassifier) PredictSingle ¶
func (kc *KNNClassifier) PredictSingle(input Datum) (Datum, error)
PredictSingle finds the "closest" known Sample the given Datum, and returns
the associated output.
func (*KNNClassifier) Save ¶
func (kc *KNNClassifier) Save(path string) error
Save saves a KNNClassifier to disk.
type Predictor ¶
type Predictor interface { Fit(samples []Sample) error Predict(input []Datum) ([]Datum, error) PredictSingle(input Datum) (Datum, error) Save(path string) error }
Predictor defines the methods necessary to Train, Predict, and Save a
ML model. The design is influence by scikit-learn (https://scikit-learn.org/stable/about.html).
type Transformer ¶
type Transformer interface { Fit(samples []Datum) error Transform(input []Datum) ([]Datum, error) TransformSingle(input Datum) (Datum, error) Save(path string) error }
Transformer defines the methods to Train, Predict, and Save a pre-processing
model. The key difference from a Predictor is that it doesn't fit against Samples, but just raw input Datum.