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 Hyperparameters1) 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.

{}

ann

Autoregressive approximate nearest neighbors built on Lance.

auto_elastic_net

ElasticNet forecaster with automated lags and hyperparameters selection.

auto_knn

KNN forecaster with automated lags and hyperparamters selection.

auto_lasso

LASSO forecaster with automated lags and hyperparameters selection.

auto_lightgbm

LightGBM forecaster with automated lags and hyperparamters selection.

auto_linear_model

Autoregressive linear forecaster with automated lags selection.

auto_ridge

Ridge forecaster with automated lags and hyperparameters selection.

censored_model

Censored forecaster given threshold parameter (defaults to 0.0).

Two separate forecasters are fit above and below a certain threshold. The forecasts are then combined using a binary classifier where: {0: "below_threshold", 1: "above_threshold"}.

elastic_net

Autoregressive ElasticNet forecaster.

elastic_net_cv

Autoregressive ElasticNetCV forecaster.

flaml_lightgbm

Autoregressive FLAML LightGBM forecaster with automated lags and hyperparameter tuning.

lasso

Autoregressive LASSO forecaster.

lasso_cv

Autoregressive LassoCV forecaster.

linear_model

Autoregressive linear forecaster.

ridge

Autoregressive Ridge forecaster.

ridge_cv

Autoregressive RidgeCV forecaster.

zero_inflated_model

Censored forecaster with threshold at 0.


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