Global model
polars_ts.global_model
Global forecasting model — one model across all series.
Implements Ch 10 of "Modern Time Series Forecasting with Python" (2nd Ed.). A global model pools data from all time series and optionally encodes series identity and static features.
GlobalForecaster
Train a single ML model across all time series in a panel.
Extends :class:ForecastPipeline with cross-series learning,
optional series-identity encoding, and static exogenous features.
Parameters
estimator
A scikit-learn-compatible estimator with fit and predict.
lags
Lag offsets for lag features.
rolling_windows
Window sizes for rolling aggregations.
rolling_aggs
Aggregation functions for rolling features.
calendar
Calendar features to extract.
fourier
Fourier term specs as [(period, n_harmonics), ...].
target_transform
Optional transform: "log", "boxcox", or "difference".
transform_kwargs
Arguments passed to the transform function.
encode_id
How to encode series identity:
"ordinal" maps each ID to an integer,
"onehot" creates binary indicator columns.
None (default) does not encode the ID.
static_features
Column names of static (per-series) exogenous features to
include in the feature matrix (e.g. ["store_type"]).
String columns are ordinal-encoded automatically.
target_col
Column with the target values.
id_col
Column identifying each time series.
time_col
Column with timestamps.
fit(df)
Fit a single model on pooled data from all time series.
Parameters
df
Training DataFrame with id_col, time_col, target_col,
and any static_features columns.
Returns
GlobalForecaster
Fitted model (self).
predict(df, h)
Generate h-step-ahead forecasts for all series.
Parameters
df
DataFrame containing history to predict from. Must include
any static_features columns.
h
Forecast horizon.
Returns
pl.DataFrame
DataFrame with columns [id_col, time_col, "y_hat"].
_build_extra_features(gid)
Build the identity + static feature vector for a series.
_transform_buffer(values)
Transform raw values into the model's working space.
_inverse_single(pred, orig_values)
Inverse-transform a single prediction to original scale.