Documentation
¶
Overview ¶
Package knn implements a K Nearest Neighbors object, capable of both classification and regression. It accepts data in the form of a slice of float64s, which are then reshaped into a X by Y matrix.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KNNClassifier ¶
type KNNClassifier struct { base.BaseEstimator TrainingData base.FixedDataGrid DistanceFunc string NearestNeighbours int AllowOptimisations bool }
A KNNClassifier consists of a data matrix, associated labels in the same order as the matrix, and a distance function. The accepted distance functions at this time are 'euclidean' and 'manhattan'. Optimisations only occur when things are identically group into identical AttributeGroups, which don't include the class variable, in the same order.
func NewKnnClassifier ¶
func NewKnnClassifier(distfunc string, neighbours int) *KNNClassifier
NewKnnClassifier returns a new classifier
func (*KNNClassifier) Fit ¶
func (KNN *KNNClassifier) Fit(trainingData base.FixedDataGrid)
Fit stores the training data for later
func (*KNNClassifier) Predict ¶
func (KNN *KNNClassifier) Predict(what base.FixedDataGrid) base.FixedDataGrid
Predict returns a classification for the vector, based on a vector input, using the KNN algorithm.
type KNNRegressor ¶
type KNNRegressor struct { base.BaseEstimator Values []float64 DistanceFunc string }
A KNNRegressor consists of a data matrix, associated result variables in the same order as the matrix, and a name.
func NewKnnRegressor ¶
func NewKnnRegressor(distfunc string) *KNNRegressor
NewKnnRegressor mints a new classifier.