ice-skaters
skaters on a river: calibrated forecast features for streaming ML pipelines.
The idea
Every numeric stream is replaced by two scalars from its own online Laplace forecaster: the predictive mean, which is what the forecaster expected this value to be, and the standardized surprise z, which is how unexpected the actual value was, bounded near |z| = 7 by construction. The mean carries the level. The z carries the news. A wild observation can move the pair only so far, and that bounded influence is where the robustness comes from.
Install
pip install ice-skaters
Quickstart
from river import datasets, linear_model, metrics, preprocessing
from ice_skaters import LaplaceFeatures, LaplaceTarget
model = LaplaceTarget(
regressor=preprocessing.TargetStandardScaler(
regressor=LaplaceFeatures()
| preprocessing.StandardScaler()
| linear_model.LinearRegression()))
mae = metrics.MAE()
for x, y in datasets.TrumpApproval():
pred = model.predict_one(x)
mae.update(y, pred if pred is not None else 0.0)
model.learn_one(x, y)
LaplaceFeatures is a river transformer for the input
streams. LaplaceTarget wraps any regressor to add the
target's own pair, which a transformer cannot do since it never sees y.
Both pipe, pickle and deep-copy like any river estimator. Details in the
guide.
What you get
On TrumpApproval with river's recommended pipeline, progressive validation MAE with a burn-in of 100:
| clean | 2% corrupted readings | |
|---|---|---|
| StandardScaler pipeline | 0.328 | 0.597 |
| + Laplace front-end | 0.382 | 0.407 |
The front-end pays a small toll on clean data and holds its footing when the inputs misbehave. In controlled simulation the same substitution beats raw features, a running z-score, a median/MAD winsorizer and a Huberised loss 30 seeds out of 30 under every contamination type tested. The full protocols and numbers are on the papers page, including the cases where the front-end loses, because it does lose some.
Relation to the stack
skaters does one thing: fast univariate distributional forecasting, stdlib-only, in Python or the browser. timemachines builds anomaly detection on the same calibrated surprise streams. ice-skaters is the bridge from those streams to river's estimator protocol, and nothing more.