k-Nearest Neighbor (KNN).
Initialize the Knn class.
Input
- k - [integer] number of NN
- dist - [string] adopted distance (‘se’ = SQUARED EUCLIDEAN, ‘e’ = EUCLIDEAN)
Store x and y data.
Input
- x - [2D numpy array float] (#sample x #feature) training data
- y - [1D numpy array integer] classes
- -1 or 1 for binary classification
- 1, ..., nclasses for multiclass classification
Output
- 1
Predict knn model on a test point(s).
Input
- p - [1D or 2D numpy array float] test point(s)
Output: the predicted value(s) on success:
- -1 or 1 for binary classification
- 1, ..., nclasses for multiclass classification
- 0 on succes with non unique classification
- -2 otherwise