Case 2: Estimating object relevance
Implementation in RubixML
Below is a runnable RubixML example: train Ridge on a small dataset and predict relevance for a new object.
Example of use
<?php
use Rubix\ML\Datasets\Unlabeled;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Regressors\Ridge;
$samples = [
[10, 5, 2],
[4, 1, 0],
[20, 8, 5],
];
$labels = [8, 2, 15];
$dataset = new Labeled($samples, $labels);
$model = new Ridge(1.0);
$model->train($dataset);
$newSample = [[9, 6, 4]];
$prediction = $model->predict(new Unlabeled($newSample));
print_r($prediction);
Result:
Memory: 1.063 Mb
Time running: 0.014 sec.
Array
(
[0] => 8.1755577109603
)
Takeaway: RubixML lets you replace a manual formula with a model that learns from data and adapts feature contributions.