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

#include <Perceptron.h>

Inheritance diagram for Perceptron:
ANNClassifier Classifier Predictor

Public Member Functions

 Perceptron (double _eta=0.01, int iter=10)
 
void fit (const Matrix< double > &X, const Matrix< double > &y) override
 
Matrix< double > netInput (const Matrix< double > &X) override
 
Matrix< double > activation (const Matrix< double > &X) override
 
Matrix< double > predict (const Matrix< double > &X) override
 
double costFunction (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
 

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

Represents Perceptron definition by Frank Rosenblatt

Wikipedia

Essentially it can be used to build binary classification One might for example want to replace some very complex binary operation which is a combination of several broad operations like OR|AND|XOR|NOT ...

In order to use the perceptron classifier one needs access to the full set of possible transformations.

THIS IS NOT A PREDICTOR

Mainly implemented for academic use

Examples
ds/TestPerceptron.cpp.

Constructor & Destructor Documentation

◆ Perceptron()

Perceptron::Perceptron ( double  _eta = 0.01,
int  iter = 10 
)
inlineexplicit

default constructor

Parameters
_eta
iter

Member Function Documentation

◆ activation()

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

activate given input

Parameters
X
Returns

Implements ANNClassifier.

◆ costFunction()

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

cost function override, don't use!

Parameters
X
Returns

Implements ANNClassifier.

◆ fit()

void Perceptron::fit ( const Matrix< double > &  X,
const Matrix< double > &  y 
)
inlineoverridevirtual
Parameters
Xarray-like with the shape: [n_samples, n_features]
yarray-like with shape: [n_samples, 1]
Returns
this

Implements Predictor.

◆ netInput()

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

calculates net input

\[ X * weights + b \]

Parameters
X
Returns

Implements ANNClassifier.

◆ predict()

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

predict class of given input

Parameters
X
Returns

Implements Predictor.


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