Quantile regression
polars_ts.probabilistic.quantile_regression
Quantile regression forecaster for prediction intervals.
Trains one model per quantile level using any scikit-learn-compatible
estimator that supports quantile loss (e.g. GradientBoostingRegressor
with loss='quantile').
QuantileRegressor
Quantile regression forecaster producing prediction intervals.
Trains one model per quantile level. At prediction time, generates recursive multi-step forecasts for each quantile, using the median (q=0.5) prediction as the recursive input.
Parameters
estimator_factory
Callable that takes a quantile level (float in (0, 1)) and
returns a fresh scikit-learn-compatible estimator.
Example: lambda q: GradientBoostingRegressor(loss='quantile', alpha=q).
quantiles
Quantile levels to predict (e.g. [0.1, 0.5, 0.9]).
lags
Lag offsets used as features (e.g. [1, 2, 7]).
target_col
Column with the target values.
id_col
Column identifying each time series.
time_col
Column with timestamps for ordering.
fit(df)
Fit one estimator per quantile on lag features derived from df.
All series are pooled together for a single global model per quantile.
Parameters
df
Training DataFrame with at least id_col, time_col, and
target_col.
Returns
QuantileRegressor
Fitted regressor (self).
predict(df, h)
Generate h-step-ahead quantile forecasts by recursive prediction.
The median quantile (closest to 0.5) is used as the recursive input for subsequent steps.
Parameters
df DataFrame containing the history to predict from. h Forecast horizon (number of steps ahead).
Returns
pl.DataFrame
DataFrame with columns [id_col, time_col, "y_hat", "q_0.1", ...].
The y_hat column uses the median quantile prediction.
Quantile columns are named q_<level> for CRPS compatibility.