Forecaster
polars_ts.agents.forecaster
ForecasterAgent: model fitting, validation, and adaptive ensemble selection.
ForecastAgentResult
dataclass
Output of the ForecasterAgent.
ForecasterAgent
Fits candidate models, validates, and selects the best or builds an ensemble.
Parameters
backend LLM backend for guided decisions. Defaults to rule-based heuristics. id_col Column identifying each time series. time_col Column with timestamps. target_col Column with target values.
_add_id_col(df)
Add a synthetic id column when the data has none.
_drop_id_col(df)
Remove the synthetic id column.
forecast(df, plan)
Fit each candidate model and select the best by validation MAE.
_ensemble_forecast(df, plan, scores, all_preds, valid_models, best_name, added_id=False)
Build a weighted ensemble of top models using inverse-MAE weights.
_weighted_average(preds_list)
Compute weighted average of y_hat across model predictions.
_train_val_split(df, h)
Split each series: last h observations go to validation.
_score(val, preds)
Compute MAE between validation actuals and predictions.