74 lines
2.8 KiB
PHP
74 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Training;
|
|
|
|
use App\Models\NetworksTraining\ADALINEPerceptronTraining;
|
|
use App\Services\DatasetReader\LinearOrderDataSetReader;
|
|
use App\Services\SynapticWeightsProvider\ZeroSynapticWeights;
|
|
use Tests\Services\IterationEventBuffer\DullIterationEventBuffer;
|
|
|
|
class ADALINEPerceptronTest extends TrainingTestCase
|
|
{
|
|
public function test_adaline_perceptron_training_logic_and()
|
|
{
|
|
$training = new ADALINEPerceptronTraining(
|
|
datasetReader: new LinearOrderDataSetReader(public_path('data_sets/logic_and_gradient.csv')),
|
|
learningRate: 0.03,
|
|
maxEpochs: 10000,
|
|
synapticWeightsProvider: new ZeroSynapticWeights,
|
|
iterationEventBuffer: new DullIterationEventBuffer,
|
|
sessionId: 'test-session',
|
|
trainingId: 'test-training',
|
|
minError: 0.1251,
|
|
);
|
|
|
|
$this->verifyTrainingResults(
|
|
training: $training,
|
|
expectedWeights: [[[-1.503867, 0.992594, 0.976844]]],
|
|
expectedEpochs: 202,
|
|
marginOfError: 0.1,
|
|
);
|
|
}
|
|
|
|
// public function test_adaline_perceptron_training_table_2_9()
|
|
// {
|
|
// $training = new ADALINEPerceptronTraining(
|
|
// datasetReader: new LinearOrderDataSetReader(public_path('data_sets/table_2_9.csv')),
|
|
// learningRate: 0.0012,
|
|
// maxEpochs: 1000,
|
|
// synapticWeightsProvider: new ZeroSynapticWeights(),
|
|
// iterationEventBuffer: new DullIterationEventBuffer(),
|
|
// sessionId: 'test-session',
|
|
// trainingId: 'test-training',
|
|
// minError: 5.670337, // Impossible pour un dataset avec des labels -1 et 1 d'avoir une erreur moyenne supérieure à 2
|
|
// );
|
|
|
|
// $this->verifyTrainingResults(
|
|
// training: $training,
|
|
// expectedWeights: [[[-0.664816, -0.522798, 0.342044]]],
|
|
// expectedEpochs: 92
|
|
// );
|
|
// }
|
|
|
|
public function test_adaline_perceptron_training_table_2_10()
|
|
{
|
|
$training = new ADALINEPerceptronTraining(
|
|
datasetReader: new LinearOrderDataSetReader(public_path('data_sets/table_2_10.csv')),
|
|
learningRate: 0.0015,
|
|
maxEpochs: 1000,
|
|
synapticWeightsProvider: new ZeroSynapticWeights,
|
|
iterationEventBuffer: new DullIterationEventBuffer,
|
|
sessionId: 'test-session',
|
|
trainingId: 'test-training',
|
|
// minError: 16.597077, // Impossible pour un dataset avec des labels -1 et 1 d'avoir une erreur moyenne supérieure à 2
|
|
minError: 0.000000001,
|
|
);
|
|
|
|
$this->verifyTrainingResults(
|
|
training: $training,
|
|
expectedWeights: [[[-0.022673, -0.25422, 0.294955]]],
|
|
expectedEpochs: 1000
|
|
);
|
|
}
|
|
}
|