Metrics#

Validation metrics are for used evaluating the performance of an estimator. They output a score based on the predictions and the ground-truth found in the labels.

Scoring Predictions#

To compute a validation score, pass in the predictions from an estimator along with the expected labels:

public score(array $predictions, array $labels) : float
use Rubix\ML\CrossValidation\Metrics\MeanAbsoluteError;

$predictions = $estimator->predict($dataset);

$metric = new MeanAbsoluteError();

$score = $metric->score($predictions, $dataset->labels());

var_dump($score);
float(-0.99846070553066)

Note: Regression metrics output the negative of their value to maintain the notion that cross validation scores should be maximized instead of minimized such as the case with loss functions.

Output Range#

Output the range of values the validation score can take on in a 2-tuple:

public range() : array
[$min, $max] = $metric->range();

var_dump($min);
var_dump($max);
float(-INF)

int(0)