Skip to content

Metrics auc trapezoid

github-actions[bot] edited this page Aug 26, 2026 · 24 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Metrics is 0.3.0 — read its documentation.

Auc.Trapezoid

The trapezoidal area under a curve given as points — sklearn.metrics.auc.

public static double Trapezoid(ReadOnlySpan<double> x, ReadOnlySpan<double> y)

Parametersx is the x coordinates, monotonic in either direction, and y the y coordinates, one per x.

Returnsdouble, 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.

ExceptionsArgumentException 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.75

Remarks — 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 alsoRocCurve.Compute, RocAuc.Score, AveragePrecision.Score, the Python equivalence table.

Lodestar

Project

Clone this wiki locally