This commit is contained in:
Netkas 2023-02-07 19:23:00 -05:00
parent 6f11ff674d
commit b74c906a12
3 changed files with 399 additions and 0 deletions

39
tests/model_test.php Normal file
View file

@ -0,0 +1,39 @@
<?php
require 'ncc';
import('net.nosial.alizelib');
$model = new \AlizeLib\GeneralizationModel(100);
function random_float ($min,$max)
{
return ($min+lcg_value()*(abs($max-$min)));
}
// Add random high float values to the model under label "en" x 150 times
for($i = 0; $i < 150; $i++)
{
$model->add("en", random_float(0.5, 1));
}
// Add random low float values to the model under label "zh" x 150 times
for($i = 0; $i < 150; $i++)
{
$model->add("zh", random_float(0, 0.5));
}
// Add random very low float values to the model under label "fr" x 150 times
for($i = 0; $i < 150; $i++)
{
$model->add("fr", random_float(0, 0.1));
}
// Add random very high float values to the model under label "de" x 150 times
for($i = 0; $i < 150; $i++)
{
$model->add("de", random_float(0.9, 1));
}
var_dump($model->calculateBestLabels());