philsupertramp/game-math
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
AdalineSGD Class Reference

#include <AdalineSGD.h>

Inheritance diagram for AdalineSGD:
ANNClassifier Classifier Predictor

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...
 

Detailed Description

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.

Examples
ds/TestAdalineSGD.cpp.

Constructor & Destructor Documentation

◆ AdalineSGD()

AdalineSGD::AdalineSGD ( double  _eta = 0.01,
int  iter = 10,
bool  _shuffle = false,
int  _randomState = 0 
)
inlineexplicit

default constructor

Parameters
_etalearning rate
iternumber of learning iterations
_shuffleuse shuffled data
_randomStateseed of random state

Member Function Documentation

◆ activation()

Matrix< double > AdalineSGD::activation ( const Matrix< double > &  X)
inlineoverridevirtual

activates given input

Parameters
Xinput values
Returns
activated input values

Implements ANNClassifier.

◆ costFunction()

double AdalineSGD::costFunction ( const Matrix< double > &  X)
inlineoverridevirtual

Do not use

Parameters
X
Returns

Implements ANNClassifier.

◆ fit()

void AdalineSGD::fit ( const Matrix< double > &  X,
const Matrix< double > &  y 
)
inlineoverridevirtual

fit weights using sgd member

Parameters
Xarray-like with the shape: [n_samples, n_features]
yarray-like with shape: [n_samples, 1]
Returns
this

Implements Predictor.

◆ netInput()

Matrix< double > AdalineSGD::netInput ( const Matrix< double > &  X)
inlineoverridevirtual

alias for sdg.netInput

Parameters
Xinput values
Returns

Implements ANNClassifier.

◆ partial_fit()

void AdalineSGD::partial_fit ( const Matrix< double > &  X,
const Matrix< double > &  y 
)
inline

partially fits the model

Parameters
Xinput values
ytarget output values

◆ predict()

Matrix< double > AdalineSGD::predict ( const Matrix< double > &  X)
inlineoverridevirtual

predict output class of given input

Parameters
Xinput values
Returns
predicted output

Implements Predictor.

Member Data Documentation

◆ randomState

int AdalineSGD::randomState

initialize weights with random state

◆ sgd

SGD AdalineSGD::sgd

algorithmic object to represent fitting algorithm

◆ shuffle

bool AdalineSGD::shuffle

signalizes whether given dataset should be shuffled while fitting


The documentation for this class was generated from the following file: