Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
Phpml\Classification\Linear\Adaline Class Reference
Inheritance diagram for Phpml\Classification\Linear\Adaline:
Phpml\Classification\Linear\Perceptron Phpml\Classification\Classifier Phpml\IncrementalEstimator Phpml\Estimator

Public Member Functions

 __construct (float $learningRate=0.001, int $maxIterations=1000, bool $normalizeInputs=true, int $trainingType=self::BATCH_TRAINING)
 Initalize an Adaline (ADAptive LInear NEuron) classifier with given learning rate and maximum number of iterations used while training the classifier

 
 getCostValues ()
 Returns the cost values obtained during the training.
 
 partialTrain (array $samples, array $targets, array $labels=[])
 
 predict (array $samples)
 
 setEarlyStop (bool $enable=true)
 Normally enabling early stopping for the optimization procedure may help saving processing time while in some cases it may result in premature convergence.
 
 train (array $samples, array $targets)
 
 trainBinary (array $samples, array $targets, array $labels)
 

Public Attributes

const BATCH_TRAINING = 1
 
const ONLINE_TRAINING = 2
 Online training: Stochastic gradient descent learning.
 

Protected Member Functions

 checkNormalizedSample (array $sample)
 Checks if the sample should be normalized and if so, returns the normalized sample.
 
 output (array $sample)
 Calculates net output of the network as a float value for the given input.
 
 outputClass (array $sample)
 Returns the class value (either -1 or 1) for the given input.
 
 predictProbability (array $sample, $label)
 Returns the probability of the sample of belonging to the given label.
 
 predictSampleBinary (array $sample)
 
 resetBinary ()
 
 runGradientDescent (array $samples, array $targets, Closure $gradientFunc, bool $isBatch=false)
 Executes a Gradient Descent algorithm for the given cost function.
 
 runTraining (array $samples, array $targets)
 Adapts the weights with respect to given samples and targets by use of gradient descent learning rule.
 

Protected Attributes

bool $enableEarlyStop = true
 
int $featureCount = 0
 
array $labels = []
 
float $learningRate
 
int $maxIterations
 
Normalizer $normalizer
 
Optimizer GD StochasticGD null $optimizer
 
string int $trainingType
 Training type may be either 'Batch' or 'Online' learning.
 
array $weights = []
 

Constructor & Destructor Documentation

◆ __construct()

Phpml\Classification\Linear\Adaline::__construct ( float $learningRate = 0.001,
int $maxIterations = 1000,
bool $normalizeInputs = true,
int $trainingType = self::BATCH_TRAINING )

Initalize an Adaline (ADAptive LInear NEuron) classifier with given learning rate and maximum number of iterations used while training the classifier

Learning rate should be a float value between 0.0(exclusive) and 1.0 (inclusive)
Maximum number of iterations can be an integer value greater than 0
If normalizeInputs is set to true, then every input given to the algorithm will be standardized by use of standard deviation and mean calculation

Exceptions
InvalidArgumentException

Member Function Documentation

◆ output()

Phpml\Classification\Linear\Perceptron::output ( array $sample)
protectedinherited

Calculates net output of the network as a float value for the given input.

Return values
int|float

◆ partialTrain()

Phpml\Classification\Linear\Perceptron::partialTrain ( array $samples,
array $targets,
array $labels = [] )
inherited

◆ predict()

Phpml\Estimator::predict ( array $samples)
inherited

Implemented in Phpml\Pipeline.

◆ predictProbability()

Phpml\Classification\Linear\Perceptron::predictProbability ( array $sample,
$label )
protectedinherited

Returns the probability of the sample of belonging to the given label.

The probability is simply taken as the distance of the sample to the decision plane.

Parameters
mixed$label

◆ predictSampleBinary()

Phpml\Classification\Linear\Perceptron::predictSampleBinary ( array $sample)
protectedinherited
Return values
mixed

◆ runTraining()

Phpml\Classification\Linear\Adaline::runTraining ( array $samples,
array $targets )
protected

Adapts the weights with respect to given samples and targets by use of gradient descent learning rule.

Reimplemented from Phpml\Classification\Linear\Perceptron.

◆ setEarlyStop()

Phpml\Classification\Linear\Perceptron::setEarlyStop ( bool $enable = true)
inherited

Normally enabling early stopping for the optimization procedure may help saving processing time while in some cases it may result in premature convergence.


If "false" is given, the optimization procedure will always be executed for $maxIterations times

Return values
$this

◆ train()

Phpml\Estimator::train ( array $samples,
array $targets )
inherited

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