Skip to content

Metrics jaccardscore perclass

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.

JaccardScore.PerClass

One coefficient per class, in label order — jaccard_score(average=None).

public static double[] PerClass(ReadOnlySpan<int> yTrue, ReadOnlySpan<int> yPred, ZeroDivision zeroDivision = ZeroDivision.Zero, ReadOnlySpan<int> labels = default, ReadOnlySpan<double> sampleWeight = default)

ParametersyTrue and yPred are the labels to count a matrix from. zeroDivision is the answer for a class neither side carries. labels fixes the label set and its order. sampleWeight is one weight per sample.

Returns — a fresh double[], one entry per class in label order.

ExceptionsArgumentException when the inputs disagree in length or the weights do not match. UndefinedMetricException when a class is empty on both sides and zeroDivision is ZeroDivision.Throw.

Example — the per-class view the averages hide.

using Lodestar.Metrics;

int[] truth = [0, 1, 2, 1];
int[] predicted = [0, 2, 2, 1];

double[] perClass = JaccardScore.PerClass(truth, predicted);
double second = perClass[1];  // => 0.5

The three classes score 1, 0.5 and 0.5, whose plain mean is the 0.6666… JaccardScore.Score reports under Averaging.Macro.

Applies to — net10.0, netstandard2.0.

See alsoJaccardScore.Score, Precision.PerClass, the Python equivalence table.

Lodestar

Project

Clone this wiki locally