Skip to content

Metrics poissondeviance score

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

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

PoissonDeviance.Score

The mean Poisson deviance — sklearn.metrics.mean_poisson_deviance.

public static double Score(ReadOnlySpan<double> yTrue, ReadOnlySpan<double> yPred, ReadOnlySpan<double> sampleWeight = default)

ParametersyTrue is the true counts, which must be non-negative, and yPred the predicted rates, which must be strictly positive and the same length. sampleWeight is one weight per sample, or empty — the default — to weight every sample by 1.

Returnsdouble, 0 for a perfect prediction and larger the worse it is. Unbounded above.

ExceptionsArgumentException when the lengths disagree, the input is empty or holds a non-finite value, a truth is negative, or a prediction is not strictly positive. The message is scikit-learn's, and names power=1: this is TweedieDeviance at that power and shares its refusal.

Example — four counts against a model's predicted rates.

using Lodestar.Metrics;

double[] counts = [1.0, 2.0, 3.0, 4.0];
double[] rates = [1.5, 2.5, 2.0, 4.5];

double deviance = PoissonDeviance.Score(counts, rates);  // => 0.1967…

A zero count is fine, and contributes only the ŷ − y part of the term:

using Lodestar.Metrics;

double[] counts = [0.0, 2.0, 3.0];
double[] rates = [1.0, 2.0, 3.0];

double withZero = PoissonDeviance.Score(counts, rates);  // => 0.6666…

Remarks — identical to TweedieDeviance.Score at power: 1.0, asserted across the whole frozen corpus rather than on one pair.

Applies to — net10.0, netstandard2.0.

See alsoGammaDeviance.Score, TweedieDeviance.Score, D2Tweedie.Score, the Python equivalence table.

Lodestar

Project

Clone this wiki locally