Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Forecasting wrappers #1491

Open
TonyBagnall opened this issue May 3, 2024 · 6 comments
Open

[ENH] Forecasting wrappers #1491

TonyBagnall opened this issue May 3, 2024 · 6 comments
Labels
enhancement New feature, improvement request or other non-bug code enhancement forecasting Forecasting package

Comments

@TonyBagnall
Copy link
Contributor

TonyBagnall commented May 3, 2024

Describe the feature or idea you want to propose

To kick off the review of forecasting and hopeful eventual move away from huge collections of wrappers, I will audit the current state of forecasting, describing what is wrapped and what is implemented (if anything!). This is a WIP

To make this tractable, I will split it into issues and comments

Classes in aeon.forecasting

The model is adapters in base/adapters.

  • FBProphet: _ProphetAdapter
    subclasses: Prophet (prophet.py)
  • pmdarima
    subclasses: ARIMA, AutoARIMA (arima.py)
  • StatsForecast:
    sublcasses: StatsForecastAutoARIMA
  • tbats:
    subclasses: TBATS
  • StatsModels
    sub classes
    ARDML (ardl.py)
    DynamicFactor (dynamic_factor.py)
    AutoETS (ets.py)
    ExponentialSmoothing (exp_smoothing.py) and ThetaForecaster (theta.py)
    SARIMAX (sarimax.py)
    UnobservedComponents (structural.py)
    VAR (var.py)
    VARMAX (varmax.py)
    VECM (vecm.py)
Other forecasters that extend BaseForecaster directly

- Croston: native implementation that converts to numpy

  • ConformalIntervals: wrapper for other forecasters
  • ReconcilerForecaster: wrapper to summarise multiple forecasts
  • SquaringResiduals: wrapper to square residuals
  • TrendForecaster: some form of window based regressor
  • NaiveForecaster: extends _BaseWindowForecaster
@TonyBagnall TonyBagnall added the enhancement New feature, improvement request or other non-bug code enhancement label May 3, 2024
@TonyBagnall
Copy link
Contributor Author

TonyBagnall commented May 4, 2024

forecasting.compose

this is a complex module with a lot in it. The structure is inconsistent, and there are multiple variations of inheritance. Most of the code is in the reduce file, so will do that separately.

The base classes are BaseForecaster, _HeterogenousEnsembleForecaster, _HeterogenousMetaEstimator and _DelegatedForecaster

  • _HeterogenousEnsembleForecaster: extends _HeterogenousMetaEstimator, BaseForecaster. It contains constructor parameter self.forecasters and attribute self.forecasters_ and private undocumented methods _check_forecasters, _fit_forecasters, and _predict_forecasters and _update

  • _HeterogenousMetaEstimator has no base class. It is around 800 lines long. It has class attributes _steps_attr (default "_steps") and _steps_fitted_attr, public methods get_params, set_params and private partially documented methods _get_fitted_params, is_composite, _get_params, _set_params, _replace_estimator, _check_names, _subset_dict_keys, _check_estimators, _coerce_estimator_tuple, _get_estimator_list, _get_estimator_tuples, _get_estimator_names, _make_strings_unique, _dunder_concat and static private method _is_name_and_est stopping now, too much. There is a lot of weird stuff in here.

  • _DelegatedForecaster yes also have one of these

extend just BaseForecaster

-BaggingForecaster

extend _HeterogenousEnsembleForecaster
  • ColumnEnsembleForecaster
  • AutoEnsembleForecaster
  • EnsembleForecaster
  • HierarchyEnsembleForecaster
  • StackingForecaster
extend _DelegatedForecaster
  • ForecastByLevel
extend _DelegatedForecaster and _HeterogenousMetaEstimator

-MultiplexForecaster

extend _HeterogenousMetaEstimator, BaseForecaster
  • _Pipeline and subclasses ForecastingPipeline, TransformedTargetForecaster, ForecastX
extend _DelegatedForecaster, BaseForecaster, _HeterogenousMetaEstimator
  • Permute

@TonyBagnall
Copy link
Contributor Author

forecasting.compose.reduce.py

these are meant for forecasting using sliding windows to reduce it to a regression problem

model is everything extends _BaseWindowForecaster which is a BaseForecaster

_BaseWindowForecaster: private methods _predict, _predict_fixed_cutoff, _predict_in_sample, _predict_last_window, _get_last_window and _predict_nan
_Reducer extends _BaseWindowForecaster. Undocumented, stores

estimator, window_length=10, transformers=None, pooling="local", private methods _is_predictable, _predict_in_sample, _get_shifted_window

  • DirectTabularRegressionForecaster and DirectTimeSeriesRegressionForecaster extend _DirectReducer extends _Reducer
  • MultioutputTabularRegressionForecaster and MultioutputTimeSeriesRegressionForecaster extend _MultioutputReducer extends _Reducer
  • RecursiveTabularRegressionForecaster and RecursiveTimeSeriesRegressionForecaster extend _RecursiveReducer extends _Reducer
  • DirRecTabularRegressionForecaster and DirRecTimeSeriesRegressionForecaster extends _DirRecReducer extend _Reducer

all this is accessed through make_reduction:

" During fitting, a sliding-window approach is used to first transform the
time series into tabular or panel data, which is then used to fit a tabular or
time-series regression estimator. During prediction, the last available data is
used as input to the fitted regression estimator to generate forecasts."

@TonyBagnall
Copy link
Contributor Author

TonyBagnall commented May 4, 2024

forecasting.stream

these extend _DelegatedForecasters, and wrap a forecaster. Strange naming;

  • UpdateRefitsEvery
  • UpdateEvery
  • DontUpdate

@TonyBagnall
Copy link
Contributor Author

forecasting.online_learning

  • OnlineEnsembleForecaster extends EnsembleForecaster extends EnsembleForecaster extends _HeterogenousEnsembleForecaster
    wrap forecasters by a weight function
    these _PredictionWeightedEnsembler which is not a BaseForecaster. They seem completely outside the aeon hierarchy:

  • HedgeExpertEnsemble not declared in init

  • NormalHedgeEnsemble

  • NNLSEnsemble

@TonyBagnall
Copy link
Contributor Author

forecasting.model_evaluation

single function evaluate

forecasting.model_selection._split

contains window splitters that extend BaseSplitter.

  • BaseSplitter extends 'BaseObjectthis is implemented as a form of iterable using yield and indexes. Hassplitand_split`, seems somewhat disjoint from the toolkit. Seems to split everything into numpy. Subclasses

  • CutoffSplitter

  • SingleWindowSplitter

  • BaseWindowSplitter

  • SlidingWindowSplitter extends BaseWindowSplitter

  • ExpandingWindowSplitter extends BaseWindowSplitter

then a function temporal_train_test_split

@TonyBagnall
Copy link
Contributor Author

forecasting.model._tune

  • BaseGridSearch extends _DelegatedForecaster
  • ForecastingGridSearchCV extends BaseGridSearch
  • ForecastingRandomizedSearchCV extends BaseGridSearch

@MatthewMiddlehurst MatthewMiddlehurst added the forecasting Forecasting package label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, improvement request or other non-bug code enhancement forecasting Forecasting package
Projects
None yet
Development

No branches or pull requests

2 participants