Skip to content

forecasting

functime supports both individual forecasters and forecasters with automated lags / hyperparameter tuning. Auto-forecasters uses FLAML to optimize both hyperparameters and number of lagged dependent variables. FLAML is a SOTA library for automated hyperparameter tuning using the CFO (Frugal Optimization for Cost-related Hyperparamters1) algorithm. All individual forecasters (e.g. lasso / xgboost) and automated forecasters (e.g. auto_lasso and auto_xgboost) implement the following API.

forecaster

Autoregressive forecaster.

Parameters:

Name Type Description Default
freq str

Offset alias supported by Polars.

required
lags int

Number of lagged target variables.

required
max_horizons Optional[int]

Maximum number of horizons to predict directly. Only applied if strategy equals "direct" or "ensemble".

None
strategy Optional[str]

Forecasting strategy. Currently supports "recursive", "direct", and "ensemble" of both recursive and direct strategies.

None
target_transform Optional[Transformer]

functime transformer to apply to y before fit. The transform is inverted at predict time.

None
feature_transform Optional[Transformer]

functime transformer to apply to X before fit and predict.

None
**kwargs Mapping[str, Any]

Additional keyword arguments passed into underlying sklearn-compatible regressor.

{}

auto_forecaster

Forecaster with automated hyperparameter tuning and lags selection.

Parameters:

Name Type Description Default
freq str

Offset alias as dictated.

required
min_lags int

Minimum number of lagged target values.

3
max_lags int

Maximum number of lagged target values.

12
max_horizons Optional[int]

Maximum number of horizons to predict directly. Only applied if strategy equals "direct" or "ensemble".

None
strategy Optional[str]

Forecasting strategy. Currently supports "recursive", "direct", and "ensemble" of both recursive and direct strategies.

None
test_size int

Number of lags.

1
step_size int

Step size between backtest windows.

1
n_splits int

Number of backtest splits.

5
time_budget int

Maximum time budgeted to train each forecaster per window and set of hyperparameters.

5
search_space Optional[dict]

Equivalent to config in FLAML

None
points_to_evaluate Optional[dict]

Equivalent to points_to_evaluate in FLAML

None
num_samples int

Number of hyper-parameter sets to test. -1 means unlimited (until time_budget is exhausted.)

-1
target_transform Optional[Transformer]

functime transformer to apply to y before fit. The transform is inverted at predict time.

None
feature_transform Optional[Transformer]

functime transformer to apply to X before fit and predict.

None
**kwargs Mapping[str, Any]

Additional keyword arguments passed into underlying sklearn-compatible regressor.

{}

functime also has the following benchmark models implemented as pure Polars queries.

naive

Naive forecaster.

Parameters:

Name Type Description Default
freq str

Offset alias supported by Polars.

required

snaive

Seasonal naive forecaster.

Parameters:

Name Type Description Default
freq str

Offset alias supported by Polars.

required
sp int

Seasonal periods.

required

  1. https://arxiv.org/abs/2005.01571