Calculate the averages, total & best of labelled values, import & export the model for later use with low overhead performance
Find a file
2023-02-21 00:48:56 -05:00
.idea Updated intellij files 2023-02-07 19:50:20 -05:00
src/AlizeLib progress 2023-02-07 19:23:00 -05:00
tests progress 2023-02-07 19:23:00 -05:00
.gitignore Initial Commit 2023-02-07 17:41:01 -05:00
.gitlab-ci.yml Initial Commit 2023-02-07 17:41:01 -05:00
LICENSE Initial Commit 2023-02-07 17:41:01 -05:00
Makefile Initial Commit 2023-02-07 17:41:01 -05:00
project.json Updated project.json 2023-02-07 19:49:57 -05:00
README.md Updated README.md 2023-02-21 00:48:56 -05:00

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