sktime.forecasting.online_learning

class sktime.forecasting.online_learning.NNLSEnsemble(n_estimators=10, loss_func=None)[source]

Bases: sktime.forecasting.online_learning._prediction_weighted_ensembler._PredictionWeightedEnsembler

Ensemble class that performs a non-negative least squares to fit to the estimators. Keeps track of all observations seen so far and fits to it.

Parameters
  • n_estimators (int) – number of estimators

  • loss_func (function) – loss function which follows sklearn.metrics API, for updating weights

update(y_pred, y_true)[source]
Resets the weights over the estimators by passing previous observations

to the weighting algorithm

Parameters
  • y_pred (np.array(), shape=(time_axis,estimator_axis)) – array with predictions from the estimators

  • y_true (np.array(), shape=(time_axis)) – array with actual values for predicted quantity

class sktime.forecasting.online_learning.NormalHedgeEnsemble(n_estimators=10, a=1, loss_func=None)[source]

Bases: sktime.forecasting.online_learning._prediction_weighted_ensembler.HedgeExpertEnsemble

Implementation of A Parameter-free Hedging Algorithm, Kamalika Chaudhuri, Yoav Freund, Daniel Hsu (2009) as a hedge-style algorithm.

Parameters
  • n_estimators (float) – number of estimators

  • T (int) – forecasting horizon (in terms of timesteps)

  • a (float) – normalizing constant

  • loss_func (function) – loss function which follows sklearn.metrics API, for updating weights

update(y_pred, y_true, low_c=0.01)[source]
Resets the weights over the estimators by passing previous observations

and updating based on Normal Hedge.

Parameters
  • y_pred (np.array(), shape=(time_axis,estimator_axis)) – array with predictions from the estimators

  • y_true (np.array(), shape=(time_axis)) – array with actual values for predicted quantity

class sktime.forecasting.online_learning.OnlineEnsembleForecaster(forecasters, ensemble_algorithm=None, n_jobs=None)[source]

Bases: sktime.forecasting.compose._ensemble.EnsembleForecaster

Online Updating Ensemble of forecasters

Parameters
  • ensemble_algorithm (ensemble algorithm) –

  • forecasters (list of (str, estimator) tuples) –

  • n_jobs (int or None, optional (default=None)) – The number of jobs to run in parallel for fit. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors.

fit(y, X=None, fh=None)[source]

Fit to training data.

Parameters
  • y (pd.Series) – Target time series to which to fit the forecaster.

  • fh (int, list or np.array, optional (default=None)) – The forecasters horizon with the steps ahead to to predict.

  • X (pd.DataFrame, optional (default=None)) – Exogenous variables are ignored

Returns

self

Return type

returns an instance of self.

update(y, X=None, update_params=False)[source]

Update fitted paramters and performs a new ensemble fit.

Parameters
  • y (pd.Series) –

  • X (pd.DataFrame) –

  • update_params (bool, optional (default=False)) –

Returns

self

Return type

an instance of self

update_predict(y_test, cv=None, X_test=None, update_params=False, return_pred_int=False, alpha=0.05)[source]

Make and update predictions iteratively over the test set.

Parameters
  • y_test (pd.Series) –

  • cv (temporal cross-validation generator, optional (default=None)) –

  • X_test (pd.DataFrame, optional (default=None)) –

  • update_params (bool, optional (default=False)) –

  • return_pred_int (bool, optional (default=False)) –

  • alpha (int or list of ints, optional (default=None)) –

Returns

  • y_pred (pd.Series) – Point predictions

  • y_pred_int (pd.DataFrame) – Prediction intervals