API Reference¶
Streaming Calibration¶
- class streamcal.StreamingIsotonicCalibrator(n_buckets=100, alpha=0.1)[source]¶
Streaming isotonic calibration with EMA + PAV.
Maintains exponential moving average of bucket outcome rates, then projects onto monotonic cone via PAV. Adapts quickly to drift while guaranteeing monotonicity.
- Parameters:
n_buckets (int) – Number of buckets for discretizing probability space.
alpha (float) – EMA smoothing factor. Larger values adapt faster to drift but have more variance. Smaller values are more stable.
Batch Calibration¶
- class streamcal.IsotonicCalibrator[source]¶
Isotonic regression calibrator (batch refit every batch).
- class streamcal.TemperatureScaling[source]¶
Temperature scaling calibrator (batch refit every batch).
- class streamcal.PlattScaling(refit_every=1)[source]¶
Platt scaling calibrator (batch refit every k batches).
- Parameters:
refit_every (int)
Metrics¶
- streamcal.brier_score(y_true, y_pred)[source]¶
Brier score: mean squared error between predictions and outcomes.
- Parameters:
y_true (ndarray[tuple[Any, ...], dtype[floating[Any]]])
y_pred (ndarray[tuple[Any, ...], dtype[floating[Any]]])
- Return type:
float
- streamcal.expected_calibration_error(y_true, y_pred, n_bins=20)[source]¶
Expected Calibration Error (ECE).
Weighted average of absolute calibration error across bins.
- Parameters:
y_true (ndarray[tuple[Any, ...], dtype[floating[Any]]])
y_pred (ndarray[tuple[Any, ...], dtype[floating[Any]]])
n_bins (int)
- Return type:
float