ProphetWrapper

class hcrystalball.wrappers.ProphetWrapper(growth='linear', changepoints=None, n_changepoints=25, changepoint_range=0.8, yearly_seasonality='auto', weekly_seasonality='auto', daily_seasonality='auto', holidays=None, seasonality_mode='additive', seasonality_prior_scale=10.0, holidays_prior_scale=10.0, changepoint_prior_scale=0.05, mcmc_samples=0, interval_width=0.8, uncertainty_samples=1000, stan_backend=None, name='prophet', conf_int=False, full_prophet_output=False, extra_seasonalities=None, extra_regressors=None, extra_holidays=None, fit_params=None, clip_predictions_lower=None, clip_predictions_upper=None, hcb_verbose=True)[source]

Bases: hcrystalball.wrappers._base.TSModelWrapper

Wrapper for prophet.Prophet model

https://facebook.github.io/prophet/docs/quick_start.html#python-api

Bring prophet to sklearn time-series compatible interface and puts fit parameters to initialization stage.

Parameters
  • name (str) – Name of the model instance, used also as column name for returned prediction.

  • conf_int (bool) – Whether confidence intervals should be also outputed.

  • full_prophet_output (bool) – Whether the predict method should output the full prophet.Prophet dataframe.

  • extra_seasonalities (list of dicts) – Dictionary will be passed to prophet.Prophet add_regressor method.

  • extra_regressors (list or list of dicts) – Dictionary will be passed to prophet.Prophet add_seasonality method.

  • extra_holidays (dict of dict) – Dict with name of the holiday and values as another dict with required ‘lower_window’ key and ‘upper_window’ key and optional ‘prior_scale’ key i.e.{‘holiday_name’: {‘lower_window’:1, ‘upper_window:1, ‘prior_scale: 10}}.

  • fit_params (dict) – Parameters passed to fit prophet.Prophet model.

  • clip_predictions_lower (float) – Minimal value allowed for predictions - predictions will be clipped to this value.

  • clip_predictions_upper (float) – Maximum value allowed for predictions - predictions will be clipped to this value.

  • hcb_verbose (bool) – Whtether to keep (True) or suppress (False) messages to stdout and stderr from the wrapper and 3rd party libraries during fit and predict

Methods Summary

fit(X, y)

Transform input data to Prophet.model required format and fit the model.

get_params([deep])

Get parameters for this estimator.

predict(X)

Adjust holidays, transform data to required format and provide predictions.

set_params(**params)

Set the parameters of this estimator.

Methods Documentation

fit(X, y)[source]

Transform input data to Prophet.model required format and fit the model.

Parameters
  • X (pandas.DataFrame) – Input features.

  • y (array_like, (1d)) – Target vector.

Returns

Return type

self

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]

Adjust holidays, transform data to required format and provide predictions.

Parameters

X (pandas.DataFrame) – Input features.

Returns

Prediction is stored in column with name being the name of the wrapper. If conf_int attribute is set to True, the returned DataFrame will have three columns, with the second and third (named ‘name’_lower and ‘name’_upper). If full_prophet_output is set to True, then full Prophet.model.predict output is returned.

Return type

pandas.DataFrame with pandas.DatetimeIndex

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