philsupertramp/game-math
|
#include <AdalineSGD.h>
Public Member Functions | |
AdalineSGD (double _eta=0.01, int iter=10, bool _shuffle=false, int _randomState=0) | |
void | fit (const Matrix< double > &X, const Matrix< double > &y) override |
void | partial_fit (const Matrix< double > &X, const Matrix< double > &y) |
Matrix< double > | netInput (const Matrix< double > &X) override |
double | costFunction (const Matrix< double > &X) override |
Matrix< double > | activation (const Matrix< double > &X) override |
Matrix< double > | predict (const Matrix< double > &X) override |
Public Member Functions inherited from ANNClassifier | |
ANNClassifier (double _eta, int _n_iter) | |
virtual Matrix< double > | activation (const Matrix< double > &)=0 |
virtual Matrix< double > | netInput (const Matrix< double > &)=0 |
virtual double | costFunction (const Matrix< double > &)=0 |
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 |
Public Attributes | |
bool | shuffle |
signalizes whether given dataset should be shuffled while fitting More... | |
int | randomState |
initialize weights with random state More... | |
SGD | sgd |
algorithmic object to represent fitting algorithm More... | |
Public Attributes inherited from Classifier | |
Matrix< double > | weights |
Vector holding weights. More... | |
Matrix< double > | costs |
Vector holding classification error per epoch. More... | |
Additional Inherited Members | |
Protected Attributes inherited from ANNClassifier | |
double | eta |
Learning rate. More... | |
int | n_iter |
number epochs More... | |
Protected Attributes inherited from Classifier | |
bool | w_initialized = false |
flag to initialize weights only once More... | |
Adaline linear neuron implementation using statistic gradient decent for training of a vector of weights and a single bias.
weights: shape [N+1 x 1] bias: shape [1, 1], first element of weights
Note: only allows binary classification and uses a single layer of weights see the description here [1] I found it very easy to understand and implement.
|
inlineexplicit |
default constructor
_eta | learning rate |
iter | number of learning iterations |
_shuffle | use shuffled data |
_randomState | seed of random state |
activates given input
X | input values |
Implements ANNClassifier.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
fit weights using sgd member
X | array-like with the shape: [n_samples, n_features] |
y | array-like with shape: [n_samples, 1] |
Implements Predictor.
partially fits the model
X | input values |
y | target output values |
predict output class of given input
X | input values |
Implements Predictor.
int AdalineSGD::randomState |
initialize weights with random state
SGD AdalineSGD::sgd |
algorithmic object to represent fitting algorithm
bool AdalineSGD::shuffle |
signalizes whether given dataset should be shuffled while fitting