|
| __construct (float $learningRate=0.001, int $maxIterations=1000, bool $normalizeInputs=true) |
| Initalize a perceptron classifier with given learning rate and maximum number of iterations used while training the perceptron.
|
|
| 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) |
|
|
| 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) |
| Trains the perceptron model with Stochastic Gradient Descent optimization to get the correct set of weights.
|
|
|
bool | $enableEarlyStop = true |
|
int | $featureCount = 0 |
|
array | $labels = [] |
|
float | $learningRate |
|
int | $maxIterations |
|
Normalizer | $normalizer |
|
Optimizer GD StochasticGD null | $optimizer |
|
array | $weights = [] |
|
◆ __construct()
Phpml\Classification\Linear\Perceptron::__construct |
( |
float | $learningRate = 0.001, |
|
|
int | $maxIterations = 1000, |
|
|
bool | $normalizeInputs = true ) |
Initalize a perceptron classifier with given learning rate and maximum number of iterations used while training the perceptron.
- Parameters
-
float | $learningRate | Value between 0.0(exclusive) and 1.0(inclusive) |
int | $maxIterations | Must be at least 1 |
- Exceptions
-
◆ output()
Phpml\Classification\Linear\Perceptron::output |
( |
array | $sample | ) |
|
|
protected |
Calculates net output of the network as a float value for the given input.
- Return values
-
◆ partialTrain()
Phpml\Classification\Linear\Perceptron::partialTrain |
( |
array | $samples, |
|
|
array | $targets, |
|
|
array | $labels = [] ) |
◆ predict()
Phpml\Estimator::predict |
( |
array | $samples | ) |
|
|
inherited |
◆ predictProbability()
Phpml\Classification\Linear\Perceptron::predictProbability |
( |
array | $sample, |
|
|
| $label ) |
|
protected |
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
-
◆ predictSampleBinary()
Phpml\Classification\Linear\Perceptron::predictSampleBinary |
( |
array | $sample | ) |
|
|
protected |
◆ runTraining()
Phpml\Classification\Linear\Perceptron::runTraining |
( |
array | $samples, |
|
|
array | $targets ) |
|
protected |
◆ setEarlyStop()
Phpml\Classification\Linear\Perceptron::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.
If "false" is given, the optimization procedure will always be executed for $maxIterations times
- Return values
-
◆ train()
Phpml\Estimator::train |
( |
array | $samples, |
|
|
array | $targets ) |
|
inherited |
The documentation for this class was generated from the following file:
- lib/mlbackend/php/phpml/src/Phpml/Classification/Linear/Perceptron.php