stat.calibration
Probability calibration diagnoses how predicted probabilities differ from observed positive rates and fits a mapping to correct them. The live stats consume com.eignex.kumulant.core.PairedStat observations (prediction, label); isotonic calibration derives a curve from a reliability snapshot.
Picking a calibration method
| Stat or projection | Mapping | Reach for it when |
|---|---|---|
| ReliabilityStat | Per-bin predicted and observed rates, plus calibration error | Diagnose calibration, plot the gaps, or retain mergeable evidence for isotonic fitting. |
| PlattCalibratorStat | sigmoid(slope * x + intercept) | Fit a smooth sigmoid with two parameters, especially when observations are scarce. |
| isotonicCalibration | Monotone probabilities with linear interpolation between bin midpoints | Fit an arbitrary monotone shape from a ReliabilityResult without a second accumulator. |
The diagnostic and correction workflow
Feed held-out
(prediction, label)pairs to ReliabilityStat.Inspect ReliabilityResult.expectedCalibrationError and the per-bin gap.
Call ReliabilityResult.isotonicCalibration to fit a monotone curve, or train PlattCalibratorStat on the pairs for a sigmoid mapping.
Apply the fitted result's
calibrate(rawProbability)at inference and monitor the calibrated outputs with a reliability stat.
The isotonic projection runs weighted Pool Adjacent Violators in O(numBins) time and memory. It reads the existing per-bin evidence and needs no update path or separate lifecycle.
Merge
ReliabilityStat adds per-bin sums, retaining the evidence across workers. Merge those snapshots before calling isotonicCalibration; fitting each shard and averaging curves loses the bin weights and pooling constraints. PlattCalibratorStat composes a paired-input adapter and a result projection over a one-feature logit model. It merges sample-weighted parameter vectors through its com.eignex.kumulant.stat.regression.glm.StochasticRegressionStat, an approximation to training on the combined observations.
Concurrency
ReliabilityStat uses independent atomic adds for its per-bin cells and bounds each snapshot's outcome sum by its total weight. Isotonic fitting operates on that detached snapshot. PlattCalibratorStat inherits the com.eignex.kumulant.stat.regression.glm.StochasticRegressionStat model: locked updates under com.eignex.kumulant.core.Concurrency.Strict and com.eignex.kumulant.core.Concurrency.HighWrite, asynchronous SGD under com.eignex.kumulant.core.Concurrency.Relaxed.
Types
Isotonic calibration derived from ReliabilityResult: a non-decreasing mapping from raw score in [0, 1] to calibrated probability, derived from a binned (positives, total) histogram via Pool Adjacent Violators.
Snapshot from PlattCalibratorStat: the learned sigmoid parameters and a helper that maps a raw classifier score to a calibrated probability.
Per-bin reliability snapshot for a binary probabilistic classifier. Bins are equal-width over [0, 1] indexed by predicted probability. Underlying sums use weights so soft labels and importance-weighted streams compose correctly.
Reliability diagram primitive for binary probabilistic forecasts. Paired input is (predictedProbability, outcome); predictions are bucketed into numBins equal-width bins across [0, 1]. Outcomes are typically {0, 1} but soft labels and weighted updates work uniformly.
Functions
Fit a monotone calibration curve to this reliability histogram using weighted Pool Adjacent Violators. Merge ReliabilityStat snapshots before fitting to retain each bin's evidence across shards.
Online Platt scaling: fits a one-feature logistic regression sigmoid(slope * rawScore + intercept) over paired (rawScore, label) observations where label is in {0, 1}. Use to fix the calibration of a classifier whose probability output is poorly aligned with the empirical positive rate.