Skip to content

[source]

Average Precision#

Average Precision measures the ability of an estimator to discriminate the positive class from every other class by looking at how well the positive-class probability ranks the samples. It is equivalent to the Area Under the Precision-Recall Curve. A score of 1.0 means that every positive sample has a higher positive-class probability than every negative sample. When one or more positive samples are present, the minimum score is determined by their prevalence and is strictly greater than 0, so a fully inverted ranking does not score 0.0. If the positive class is entirely absent from the evaluation set the score is undefined and defaults to 0.5 (chance level), which keeps a poorly stratified cross-validation fold from silently dragging down the mean score.

Note

Metric assumes probabilities are between 0 and 1 and their joint distribution sums to 1.

Estimator Compatibility: Probabilistic Classifier

Score Range: 0 to 1

Parameters#

# Name Default Type Description
1 positiveClass string or int The class considered positive when computing the average precision.

Example#

use Rubix\ML\CrossValidation\Metrics\AveragePrecision;

$metric = new AveragePrecision('cat');

$probabilities = $estimator->proba($dataset);

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