SimpleEnsemble

class hcrystalball.ensemble.SimpleEnsemble(base_learners, ensemble_func='mean', name='simple_ensemble', clip_predictions_lower=None, clip_predictions_upper=None)[source]

Bases: sklearn.base.BaseEstimator

SimpleEnsemble model, which takes a list of any hcrystalball model wrapper instance(s) as base learners and aggregates their prediction using ensemble_func.

See motivation to average forecasts from different models https://otexts.com/fpp2/combinations.html

Parameters
  • name (str) – Unique name / identifier of the model instance

  • base_learners (list) – List of fully instantiated hcrystalball model wrappers

  • ensemble_func ({'mean', 'median', 'min', 'max'}) – Function to aggregate base_learners predictions

Methods Summary

fit(X[, y])

Fit the stacking ensemble model

get_params([deep])

Get parameters for this estimator.

predict(X)

Calculate the prediction of the ensemble for a given set of date / time

set_params(**params)

Set the parameters of this estimator.

Methods Documentation

fit(X, y=None)[source]

Fit the stacking ensemble model

Parameters
Returns

A fitted SimpleEnsemble instance

Return type

SimpleEnsemble

get_params(deep=True)

Get parameters for this estimator.

Parameters

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params – Parameter names mapped to their values.

Return type

dict

predict(X)[source]

Calculate the prediction of the ensemble for a given set of date / time

Parameters

X (pandas.DataFrame) – DataFrame container with a single column, named ‘date’, containing the datetimes for which the predictions should be made.

Returns

A DataFrame container with the index being the input (date)time vector. The single column in the DataFrame contains the prediction and the column name is the name of the model (i.e. the name parameter passed to the constructor)

Return type

pandas.DataFrame

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**params (dict) – Estimator parameters.

Returns

self – Estimator instance.

Return type

estimator instance