Added ADALINE training
This commit is contained in:
53
tests/Unit/Training/ADALINEPerceptronTest.php
Normal file
53
tests/Unit/Training/ADALINEPerceptronTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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_simple_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_simple_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
|
||||
// );
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user