Metrics 0.3.0 auc trapezoid - 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.
The trapezoidal area under a curve given as points — sklearn.metrics.auc.
public static double Trapezoid(ReadOnlySpan<double> x, ReadOnlySpan<double> y)Parameters — x is the x coordinates, monotonic in either direction, and y the y coordinates,
one per x.
Returns — double, the area. A curve given right to left gives the same magnitude as the same
curve given left to right, which is what the reference does too.
Exceptions — ArgumentException when the lengths disagree, when fewer than two points are
given, or when x is neither increasing nor decreasing — a sequence that turns has no single area
under it.
Example — integrating a ROC curve this package drew.
using Lodestar.Metrics;
int[] truth = [0, 0, 1, 1];
double[] scores = [0.1, 0.4, 0.35, 0.8];
RocCurve curve = RocCurve.Compute(truth, scores);
double area = Auc.Trapezoid([.. curve.FalsePositiveRate], [.. curve.TruePositiveRate]); // => 0.75Remarks — reaching for this over a precision-recall curve is the mistake
AveragePrecision exists to avoid; see
the type page.
Applies to — net10.0, netstandard2.0.
See also — RocCurve.Compute, RocAuc.Score,
AveragePrecision.Score, the
Python equivalence table.