pycaret.time_series.blend_models#

pycaret.time_series.blend_models(estimator_list: list, method: str = 'mean', fold: int | Any | None = None, round: int = 4, choose_better: bool = False, optimize: str = 'MASE', weights: List[float] | None = None, fit_kwargs: dict | None = None, verbose: bool = True)[source]#

This function trains a EnsembleForecaster for select models passed in the estimator_list param. Trains a sktime EnsembleForecaster under the hood. Refer to it’s documentation for more details.

Example

>>> from pycaret.datasets import get_data
>>> airline = get_data('airline')
>>> from pycaret.time_series import *
>>> exp_name = setup(data = airline,  fh = 12)
>>> top3 = compare_models(n_select = 3)
>>> blender = blend_models(top3)
estimator_list: list of sktime compatible estimators

List of model objects

method: str, default = ‘mean’

Method to average the individual predictions to form a final prediction. Available Methods:

  • ‘mean’ - Mean of individual predictions

  • ‘gmean’ - Geometric Mean of individual predictions

  • ‘median’ - Median of individual predictions

  • ‘min’ - Minimum of individual predictions

  • ‘max’ - Maximum of individual predictions

fold: int or scikit-learn compatible CV generator, default = None

Controls cross-validation. If None, the CV generator in the fold_strategy parameter of the setup function is used. When an integer is passed, it is interpreted as the ‘n_splits’ parameter of the CV generator in the setup function.

round: int, default = 4

Number of decimal places the metrics in the score grid will be rounded to.

choose_better: bool, default = False

When set to True, the returned object is always better performing. The metric used for comparison is defined by the optimize parameter.

optimize: str, default = ‘MASE’

Metric to compare for model selection when choose_better is True.

weights: list, default = None

Sequence of weights (float or int) to apply to the individual model predictions. Uses uniform weights when None. Note that weights only apply ‘mean’, ‘gmean’ and ‘median’ methods.

fit_kwargs: dict, default = {} (empty dict)

Dictionary of arguments passed to the fit method of the model.

verbose: bool, default = True

Score grid is not printed when verbose is set to False.

Returns:

Trained Model