Added configuration panel datasets, back-end refactor and others
Some checks failed
linter / quality (push) Failing after 7s
tests / ci (8.4) (push) Failing after 6s
tests / ci (8.5) (push) Failing after 5s

This commit is contained in:
2026-03-12 16:38:50 +01:00
parent 650cf56045
commit 83b7aa3f3a
39 changed files with 3176 additions and 425 deletions

View File

@@ -12,7 +12,7 @@ class CsvReader {
public string $filename,
)
{
$this->file = fopen(public_path($filename), "r");
$this->file = fopen($filename, "r");
if (!$this->file) {
throw new \RuntimeException("Failed to open file: " . $filename);
}

View File

@@ -2,6 +2,6 @@
namespace App\Services;
interface ISynapticWeights {
interface ISynapticWeightsProvider {
public function generate(int $input_size): array;
}

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Services;
use Illuminate\Support\Facades\Log;
class PerceptronIterationEventBuffer {
private $data;
private int $nextSizeIncreaseThreshold;
private int $underSizeIncreaseCount = 0;
private int $MAX_SIZE = 50;
public function __construct(
private string $sessionId,
private string $trainingId,
private int $sizeIncreaseStart = 10,
private int $sizeIncreaseFactor = 2,
) {
$this->data = [];
$this->nextSizeIncreaseThreshold = $sizeIncreaseStart;
}
public function flush(): void {
event(new \App\Events\PerceptronTrainingIteration($this->data, $this->sessionId, $this->trainingId));
$this->data = [];
}
public function addIteration(int $iteration, int $exampleIndex, float $error, array $synaptic_weights): void {
$this->data[] = [
"iteration" => $iteration,
"exampleIndex" => $exampleIndex,
"error" => $error,
"weights" => $synaptic_weights,
];
if ($this->underSizeIncreaseCount <= $this->sizeIncreaseStart) { // We can still send a single date because we are under the increase start threshold
$this->underSizeIncreaseCount++;
$this->flush();
}
else if (count($this->data) >= $this->nextSizeIncreaseThreshold) {
$this->flush();
$this->nextSizeIncreaseThreshold *= $this->sizeIncreaseFactor;
if ($this->nextSizeIncreaseThreshold > $this->MAX_SIZE) {
$this->nextSizeIncreaseThreshold = $this->MAX_SIZE; // Cap the threshold to the maximum size
}
}
}
}

View File

@@ -2,7 +2,7 @@
namespace App\Services;
class RandomSynapticWeights implements ISynapticWeights {
class RandomSynapticWeights implements ISynapticWeightsProvider {
public function generate(int $input_size): array
{
$weights = [];

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Services;
class ZeroSynapticWeights implements ISynapticWeightsProvider {
public function generate(int $input_size): array
{
$weights = [];
for ($i = 0; $i < $input_size + 1; $i++) { // +1 for bias weight
$weights[] = 0; // Zero weights
}
return $weights;
}
}