kats.models.prophet module¶
- class kats.models.prophet.ProphetModel(data: kats.consts.TimeSeriesData, params: kats.models.prophet.ProphetParams)[source]¶
Bases:
Generic
[kats.models.model.ParamsType
]Model class for Prophet
This class provides fit, predict, and plot methods for Prophet model
- data¶
the input time series data as in
kats.consts.TimeSeriesData
- params¶
the parameter class definied with ProphetParams
- fit(**kwargs) → None[source]¶
fit Prophet model
- Parameters
None. –
- Returns
The fitted prophet model object
- static get_parameter_search_space() → List[Dict[str, object]][source]¶
get default parameter search space for Prophet model
- predict(steps, include_history=False, **kwargs) → pandas.core.frame.DataFrame[source]¶
predict with fitted Prophet model
- Parameters
steps – the steps or length of prediction horizon
include_history – if include the historical data, default as False
- Returns
time, fcst, fcst_lower, and fcst_upper
- Return type
The predicted dataframe with following columns
- class kats.models.prophet.ProphetParams(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, cap=None, floor=None, custom_seasonalities: Optional[List[Dict]] = None)[source]¶
Bases:
kats.consts.Params
Parameter class for Prophet model
This is the parameter class for prophet model, it contains all necessary parameters as definied in Prophet implementation: https://github.com/facebook/prophet/blob/master/python/prophet/forecaster.py
- growth¶
String ‘linear’ or ‘logistic’ to specify a linear or logistic trend.
- changepoints¶
List of dates at which to include potential changepoints. If not specified, potential changepoints are selected automatically.
- n_changepoints¶
Number of potential changepoints to include. Not used if input changepoints is supplied. If changepoints is not supplied, then n_changepoints potential changepoints are selected uniformly from the first changepoint_range proportion of the history.
- changepoint_range¶
Proportion of history in which trend changepoints will be estimated. Defaults to 0.8 for the first 80%. Not used if changepoints is specified.
- yearly_seasonality¶
Fit yearly seasonality. Can be ‘auto’, True, False, or a number of Fourier terms to generate.
- weekly_seasonality¶
Fit weekly seasonality. Can be ‘auto’, True, False, or a number of Fourier terms to generate.
- daily_seasonality¶
Fit daily seasonality. Can be ‘auto’, True, False, or a number of Fourier terms to generate.
- holidays¶
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¶
‘additive’ (default) or ‘multiplicative’.
- seasonality_prior_scale¶
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¶
Parameter modulating the strength of the holiday components model, unless overridden in the holidays input.
- changepoint_prior_scale¶
Parameter modulating the flexibility of the automatic changepoint selection. Large values will allow many changepoints, small values will allow few changepoints.
- mcmc_samples¶
Integer, if greater than 0, will do full Bayesian inference with the specified number of MCMC samples. If 0, will do MAP estimation.
- interval_width¶
Float, 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¶
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.
- cap¶
capacity, provided for logistic growth
- floor¶
floor, the fcst value must be greater than the specified floor
- custom_seasonlities¶
customized seasonalities, dict with keys “name”, “period”, “fourier_order”