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.

reset()[source]

Reset calibrator state.

Return type:

None

calibrate(p_raw)[source]

Apply monotonic calibration via interpolation.

Parameters:

p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

update(p_raw, y)[source]

Update EMA rates and recompute monotonic calibration.

Parameters:
  • p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • y (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

Batch Calibration

class streamcal.IsotonicCalibrator[source]

Isotonic regression calibrator (batch refit every batch).

reset()[source]

Reset calibrator state.

Return type:

None

calibrate(p_raw)[source]

Apply calibration to raw probabilities.

Parameters:

p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

update(p_raw, y)[source]

Calibrate and update based on outcomes.

Parameters:
  • p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • y (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

class streamcal.TemperatureScaling[source]

Temperature scaling calibrator (batch refit every batch).

reset()[source]

Reset calibrator state.

Return type:

None

calibrate(p_raw)[source]

Apply calibration to raw probabilities.

Parameters:

p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

update(p_raw, y)[source]

Calibrate and update based on outcomes.

Parameters:
  • p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • y (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

class streamcal.PlattScaling(refit_every=1)[source]

Platt scaling calibrator (batch refit every k batches).

Parameters:

refit_every (int)

reset()[source]

Reset calibrator state.

Return type:

None

calibrate(p_raw)[source]

Apply calibration to raw probabilities.

Parameters:

p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

update(p_raw, y)[source]

Calibrate and update based on outcomes.

Parameters:
  • p_raw (ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • y (ndarray[tuple[Any, ...], dtype[floating[Any]]])

Return type:

ndarray[tuple[Any, …], dtype[floating[Any]]]

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