Metrics 0.3.0 precisionrecallcurve compute - CyrilB1531/lodestar GitHub Wiki
Lodestar.Metrics 0.3.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
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)Parameters — yTrue 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.
Exceptions — ArgumentException 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; // => 1Remarks — 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 also — RocCurve.Compute, DetCurve.Compute,
AveragePrecision.Score, the
Python equivalence table.