Skip to content

Metrics 0.3.0 precisionrecallcurve compute

github-actions[bot] edited this page Aug 21, 2026 · 1 revision

Lodestar.Metrics 0.3.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

PrecisionRecallCurve.Compute

Draws the precision-recall curve — sklearn.metrics.precision_recall_curve.

public static PrecisionRecallCurve Compute(ReadOnlySpan<int> yTrue, ReadOnlySpan<double> yScore, int posLabel = 1, ReadOnlySpan<double> sampleWeight = default, bool dropIntermediate = false)

ParametersyTrue is the true labels, one per sample. yScore is a score per sample. posLabel is the label counted as positive, 1 by default. sampleWeight is one weight per sample, or empty. dropIntermediate drops points whose true-positive count matches both neighbours; false here, as the reference has it.

Returns — a PrecisionRecallCurve whose Precision and Recall are the same length and whose Thresholds is one shorter, for the reason the type page gives.

ExceptionsArgumentException when the inputs disagree in length, are empty, or hold a NaN score.

Example — the asymmetry, in one line.

using Lodestar.Metrics;

int[] truth = [0, 0, 1, 1];
double[] scores = [0.1, 0.4, 0.35, 0.8];

PrecisionRecallCurve curve = PrecisionRecallCurve.Compute(truth, scores);
int missing = curve.Precision.Count - curve.Thresholds.Count;  // => 1

Remarks — with no positive sample the recall is taken as 1 at every threshold, which is what the reference warns about and returns; AveragePrecision.Score reproduces the same substitution and its page says so.

Applies to — net10.0, netstandard2.0.

See alsoRocCurve.Compute, DetCurve.Compute, AveragePrecision.Score, the Python equivalence table.

Lodestar

Project

Clone this wiki locally