Prophet
Prophet
- class Prophet(freq=None, add_seasonality=None, add_country_holidays=None, growth='linear', growth_floor=0.0, growth_cap=None, 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, alpha=0.05, uncertainty_samples=1000, stan_backend=None, verbose=0, fit_kwargs=None)[source]
Prophet forecaster by wrapping Facebook’s prophet algorithm [1].
Direct interface to Facebook prophet, using the sktime interface. All hyper-parameters are exposed via the constructor.
Data can be passed in one of the sktime compatible formats, naming a column
dssuch as in the prophet package is not necessary.Unlike vanilla
prophet, also supports integer/range and period index:integer/range index is interpreted as days since Jan 1, 2000
PeriodIndexis converted using thepandasmethodto_timestamp
- Parameters:
- freq: str, default=None
A DatetimeIndex frequency. For possible values see https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html
- add_seasonality: dict or None, default=None
Dict with args for Prophet.add_seasonality(). Dict can have the following keys/values:
name: string name of the seasonality component.
period: float number of days in one period.
fourier_order: int number of Fourier components to use.
prior_scale: optional float prior scale for this component.
mode: optional ‘additive’ or ‘multiplicative’
condition_name: string name of the seasonality condition.
- add_country_holidays: dict or None, default=None
Dict with args for Prophet.add_country_holidays(). Dict can have the following keys/values:
country_name: Name of the country, like ‘UnitedStates’ or ‘US’
- growth: str, default=”linear”
String
'linear'or'logistic'to specify a linear or logistic trend. If'logistic'specified float for'growth_cap'must be provided.- growth_floor: float, default=0
Growth saturation minimum value. Used only if
growth="logistic", has no effect otherwise (ifgrowthis not"logistic").- growth_cap: float, default=None
Growth saturation maximum aka carrying capacity. Mandatory (float) iff
growth="logistic", has no effect and is optional, otherwise (ifgrowthis not"logistic").- changepoints: list or None, default=None
List of dates at which to include potential changepoints. If not specified, potential changepoints are selected automatically.
- n_changepoints: int, default=25
Number of potential changepoints to include. Not used if input
changepointsis supplied. Ifchangepointsis not supplied, then n_changepoints potential changepoints are selected uniformly from the firstchangepoint_rangeproportion of the history.- changepoint_range: float, default=0.8
Proportion of history in which trend changepoints will be estimated. Defaults to 0.8 for the first 80%. Not used if
changepointsis specified.- yearly_seasonality: str or bool or int, default=”auto”
Fit yearly seasonality. Can be
'auto', True, False, or a number of Fourier terms to generate.- weekly_seasonality: str or bool or int, default=”auto”
Fit weekly seasonality. Can be
'auto', True, False, or a number of Fourier terms to generate.- daily_seasonality: str or bool or int, default=”auto”
Fit daily seasonality. Can be
'auto', True, False, or a number of Fourier terms to generate.- holidays: pd.DataFrame or None, default=None
pd.DataFrame with columns holiday (string) and ds (date type) and optionally columns lower_window and upper_window which specify a range of days around the date to be included as holidays. lower_window=-2 will include 2 days prior to the date as holidays. Also optionally can have a column prior_scale specifying the prior scale for that holiday.
- seasonality_mode: str, default=’additive’
One of
'additive'or'multiplicative'.- seasonality_prior_scale: float, default=10.0
Parameter modulating the strength of the seasonality model. Larger values allow the model to fit larger seasonal fluctuations, smaller values dampen the seasonality. Can be specified for individual seasonalities using add_seasonality.
- holidays_prior_scale: float, default=10.0
Parameter modulating the strength of the holiday components model, unless overridden in the holidays input.
- changepoint_prior_scale: float, default=0.05
Parameter modulating the flexibility of the automatic changepoint selection. Large values will allow many changepoints, small values will allow few changepoints.
- mcmc_samples: int, default=0
If greater than 0, will do full Bayesian inference with the specified number of MCMC samples. If 0, will do MAP estimation.
- alpha: float, default=0.05
Width of the uncertainty intervals provided for the forecast. If mcmc_samples=0, this will be only the uncertainty in the trend using the MAP estimate of the extrapolated generative model. If mcmc.samples>0, this will be integrated over all model parameters, which will include uncertainty in seasonality.
- uncertainty_samples: int, default=1000
Number of simulated draws used to estimate uncertainty intervals. Settings this value to 0 or False will disable uncertainty estimation and speed up the calculation.
- stan_backend: str or None, default=None
str as defined in StanBackendEnum. If None, will try to iterate over all available backends and find the working one.
- fit_kwargs: dict or None, default=None
Dict with args for
Prophet.fit(). These are additional arguments passed to the optimizing or sampling functions in Stan.
- Attributes:
cutoffCut-off = “present time” state of forecaster.
fhForecasting horizon that was passed.
is_fittedWhether
fithas been called.stateState of the estimator.
References
Examples
>>> from sktime.datasets import load_airline >>> from sktime.forecasting.fbprophet import Prophet >>> # Prophet requires to have data with a pandas.DatetimeIndex >>> y = load_airline().to_timestamp(freq='M') >>> forecaster = Prophet( ... seasonality_mode='multiplicative', ... n_changepoints=int(len(y) / 12), ... add_country_holidays={'country_name': 'Germany'}, ... yearly_seasonality=True) >>> forecaster.fit(y) Prophet(...) >>> y_pred = forecaster.predict(fh=[1,2,3])
Methods
check_is_fitted([method_name])Check if the estimator has been fitted.
clone()Obtain a clone of the object with same hyper-parameters and config.
clone_tags(estimator[, tag_names])Clone tags from another object as dynamic override.
create_test_instance([parameter_set])Construct an instance of the class, using first test parameter set.
create_test_instances_and_names([parameter_set])Create list of all test instances and a list of names for them.
fit(y[, X, fh])Fit forecaster to training data.
fit_predict(y[, X, fh, X_pred])Fit and forecast time series at future horizon.
get_class_tag(tag_name[, tag_value_default])Get class tag value from class, with tag level inheritance from parents.
get_class_tags()Get class tags from class, with tag level inheritance from parent classes.
get_config()Get config flags for self.
get_fitted_params([deep])Get fitted parameters.
get_param_defaults()Get object's parameter defaults.
get_param_names([sort])Get object's parameter names.
get_params([deep])Get a dict of parameters values for this object.
get_pretrained_params([deep])Get pretrained parameters of this estimator.
get_tag(tag_name[, tag_value_default, ...])Get tag value from instance, with tag level inheritance and overrides.
get_tags()Get tags from instance, with tag level inheritance and overrides.
get_test_params([parameter_set])Return testing parameter settings for the estimator.
is_composite()Check if the object is composed of other BaseObjects.
load_from_path(serial)Load object from file location.
load_from_serial(serial)Load object from serialized memory container.
predict([fh, X])Forecast time series at future horizon.
predict_interval([fh, X, coverage])Compute/return prediction interval forecasts.
predict_proba([fh, X, marginal])Compute/return fully probabilistic forecasts.
predict_quantiles([fh, X, alpha])Compute/return quantile forecasts.
predict_residuals([y, X])Return residuals of time series forecasts.
predict_var([fh, X, cov])Compute/return variance forecasts.
pretrain(y[, X, fh])Pre-train forecaster on panel (global) data.
reset()Reset the object to a clean post-init state.
save([path, serialization_format])Save serialized self to bytes-like object or to (.zip) file.
score(y[, X, fh])Scores forecast against ground truth, using MAPE (non-symmetric).
set_config(**config_dict)Set config flags to given values.
set_params(**params)Set the parameters of this object.
set_random_state([random_state, deep, ...])Set random_state pseudo-random seed parameters for self.
set_tags(**tag_dict)Set instance level tag overrides to given values.
update(y[, X, update_params])Update cutoff value and, optionally, fitted parameters.
update_predict(y[, cv, X, update_params, ...])Make predictions and update model iteratively over the test set.
update_predict_single([y, fh, X, update_params])Update model with new data and make forecasts.

