philsupertramp/game-math
|
#include <KNN.h>
Public Member Functions | |
KNN (int neighbors) | |
void | fit (const Matrix< double > &X, const Matrix< double > &y) override |
Matrix< double > | predict (const Matrix< double > &x) override |
Public Member Functions inherited from Classifier | |
Classifier () | |
void | initialize_weights (size_t numRows, size_t numColumns=1) |
void | update_weights (const Matrix< double > &update, const Matrix< double > &delta) |
Matrix< double > | transform (const Matrix< double > &in) override |
virtual void | fit (const Matrix< double > &X, const Matrix< double > &y)=0 |
virtual Matrix< double > | predict (const Matrix< double > &)=0 |
virtual Matrix< double > | transform (const Matrix< double > &)=0 |
Private Attributes | |
int | nearest_neighbors |
Matrix< double > | trainLabels |
Additional Inherited Members | |
Public Attributes inherited from Classifier | |
Matrix< double > | weights |
Vector holding weights. More... | |
Matrix< double > | costs |
Vector holding classification error per epoch. More... | |
Protected Attributes inherited from Classifier | |
bool | w_initialized = false |
flag to initialize weights only once More... | |
K Nearest Neightbor Classifier (KNN) for linear and non-linear classification.
Works well on
Implementation:
fit model: not required
prediction:
|
inline |
K-Nearest Neighbor Classifier Prediction
Implements Predictor.
|
private |
|
private |