Metrics 0.3.0 poissondeviance score - CyrilB1531/lodestar GitHub Wiki

Lodestar.Metrics 0.3.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

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)

Parameters โ€” yTrue 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.

Returns โ€” double, 0 for a perfect prediction and larger the worse it is. Unbounded above.

Exceptions โ€” ArgumentException 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 also โ€” GammaDeviance.Score, TweedieDeviance.Score, D2Tweedie.Score, the Python equivalence table.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ