Calculate the averages, total & best of labelled values, import & export the model for later use with low overhead performance
.idea | ||
src/AlizeLib | ||
tests | ||
.gitignore | ||
.gitlab-ci.yml | ||
LICENSE | ||
Makefile | ||
project.json | ||
README.md |
AlizeLib
Calculate the averages, total & best of labelled data, import and export the model for later use.
Installation
The library can be installed using ncc:
ncc install -p "nosial/libs.alize=latest@n64"
or by adding the following to your project.json file under
the build.dependencies
section:
{
"name": "net.nosial.alizelib",
"version": "latest",
"source_type": "remote",
"source": "nosial/libs.alize=latest@n64"
}
If you don't have the n64 source configured you can add it
by running the following command:
ncc source add --name n64 --type gitlab --host git.n64.cc
Compiling from source
The library can be compiled from source using ncc:
ncc build --config release
or by running the following command:
make release
Usage
// ncc
require 'ncc';
import('net.nosial.alizelib');
// Create a new model
$size = 100; // The size of the model
$model = new \AlizeLib\GeneralizationModel($size);
// We are intentionally adding more data to the model
// than the model can hold, this is to demonstrate
// how old data is removed from the model.
// 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));
}
// Best label should be "de" or second best "en"
var_dump($model->calculateBestLabels());
License
This project is licensed under the MIT License - see the LICENSE file for details