Renamed tests + added some + misc
Some checks failed
linter / quality (push) Successful in 7m39s
tests / ci (8.4) (push) Successful in 6m10s
tests / ci (8.5) (push) Has been cancelled

This commit is contained in:
2026-03-22 16:57:12 +01:00
parent abb16aa6c1
commit 88a932391b
5 changed files with 49 additions and 7 deletions

View File

@@ -107,7 +107,7 @@ class PerceptronController extends Controller
}
break;
case 'table_2_11':
$dataset['defaultMinError'] = 1.0;
$dataset['defaultMinError'] = 0.02;
break;
}
$datasets[] = $dataset;

View File

@@ -82,7 +82,7 @@ class ADALINEPerceptronTraining extends NetworkTraining
protected function stopCondition(): bool
{
$condition = $this->epochError <= $this->minError && $this->perceptron->getSynapticWeights() !== [[0.0, 0.0, 0.0]];
$condition = $this->epochError <= $this->minError;
if ($condition === true) {
event(new PerceptronTrainingEnded('Le perceptron à atteint l\'erreur minimale', $this->sessionId, $this->trainingId));
}

View File

@@ -78,7 +78,7 @@ class GradientDescentPerceptronTraining extends NetworkTraining
protected function stopCondition(): bool
{
$condition = $this->epochError <= $this->minError && $this->perceptron->getSynapticWeights() !== [[0.0, 0.0, 0.0]];
$condition = $this->epochError <= $this->minError;
if ($condition === true) {
event(new PerceptronTrainingEnded('Le perceptron à atteint l\'erreur minimale', $this->sessionId, $this->trainingId));
}

View File

@@ -10,7 +10,7 @@ use Tests\Services\IterationEventBuffer\DullIterationEventBuffer;
class ADALINEPerceptronTest extends TrainingTestCase
{
public function test_simple_perceptron_training_logic_and()
public function test_adaline_perceptron_training_logic_and()
{
$training = new ADALINEPerceptronTraining(
datasetReader: new LinearOrderDataSetReader(public_path('data_sets/logic_and_gradient.csv')),
@@ -31,7 +31,7 @@ class ADALINEPerceptronTest extends TrainingTestCase
);
}
// public function test_simple_perceptron_training_table_2_9()
// public function test_adaline_perceptron_training_table_2_9()
// {
// $training = new ADALINEPerceptronTraining(
// datasetReader: new LinearOrderDataSetReader(public_path('data_sets/table_2_9.csv')),
@@ -50,4 +50,25 @@ class ADALINEPerceptronTest extends TrainingTestCase
// 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
);
}
}

View File

@@ -10,7 +10,7 @@ use Tests\Services\IterationEventBuffer\DullIterationEventBuffer;
class GradientDescentPerceptronTest extends TrainingTestCase
{
public function test_simple_perceptron_training_logic_and()
public function test_gradient_descent_perceptron_training_logic_and()
{
$training = new GradientDescentPerceptronTraining(
datasetReader: new LinearOrderDataSetReader(public_path('data_sets/logic_and_gradient.csv')),
@@ -30,7 +30,7 @@ class GradientDescentPerceptronTest extends TrainingTestCase
);
}
// public function test_simple_perceptron_training_table_2_9()
// public function test_gradient_descent_perceptron_training_table_2_9()
// {
// $training = new GradientDescentPerceptronTraining(
// datasetReader: new LinearOrderDataSetReader(public_path('data_sets/table_2_9.csv')),
@@ -49,4 +49,25 @@ class GradientDescentPerceptronTest extends TrainingTestCase
// expectedEpochs: 402
// );
// }
public function test_gradient_descent_perceptron_training_table_2_10()
{
$training = new GradientDescentPerceptronTraining(
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.388103, // 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.04107, -0.263527, 0.286406]]],
expectedEpochs: 1000
);
}
}