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)[source]

Bases: hcrystalball.wrappers._base.TSModelWrapper

Wrapper for fbprophet.Prophet model

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

Bring fbprophet 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 fbprophet.Prophet dataframe.

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

  • extra_regressors (list or list of dicts) – Dictionary will be passed to fbprophet.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 fbprophet.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.

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

mapping of string to any

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 pipelines). 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

object