philsupertramp/game-math
|
#include <NCC.h>
Public Member Functions | |
NCC (bool useIterative) | |
void | fit (const Matrix< double > &X, const Matrix< double > &y) override |
void | fit_batch (const Matrix< double > &X, const Matrix< double > &y, const Matrix< double > &labels) |
void | fit_iterative (const Matrix< double > &X, const Matrix< double > &y, const Matrix< double > &labels) |
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 | |
bool | use_iterative = true |
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... | |
$: $N$ training sample lables Out: $\mu_k$: $K$ class centroids
Calculates centroids iteratively, holds $K$ centroids and 1 training sample in memory at-a-time.
|
inline |
Implements training algorithm
X | array-like with the shape: [n_samples, n_features] |
y | array-like with shape: [n_samples, 1] |
Implements Predictor.
|
inline |
Batch-wise implementation of nearest centroid classifier centroid calculation.
Note: Requires all input data in memory.
Complexity: O(K * 6N)
X | given input data to calculate centroids from |
y | given labels for input data X |
labels | unique labels inside y |
|
inline |
Iterative implementation of nearest centroid classifier centroid calculation
Note: Allows streaming of input data.
Complexity: O(N * 3D)
X | input data to calculate centroids from |
y | given labels for input data X |
labels | unique labels inside y |
Prediction: In: $x$: Data point to classify $\mu_k$: $k$ class centroids Out: $$ argmin(||\mu_k - x||_2) $$
Implements Predictor.
|
private |