ProphetPiecewiseLinearTrendForecaster
Forecast time series data with a piecewise linear trend, fitted via prophet.
The forecaster uses Facebook’s prophet algorithm [1] and extracts the piecewise linear trend from it. Only hyper-parameters relevant for the trend modelling are exposed via the constructor.
Seasonalities are set to additive and “auto” detection in prophet, which means that yearly, weekly and daily seasonality are automatically detected, and included in the model if present, using prophet’s default settings.
For more granular control of components or seasonality, use sktime.forecasting.fbprophet.Prophet directly.
Data can be passed in one of the sktime compatible formats, naming a column ds such 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 * PeriodIndex is converted using the pandas method to_timestamp
Schnellstart
from sktime.forecasting.trend import ProphetPiecewiseLinearTrendForecaster
estimator = ProphetPiecewiseLinearTrendForecaster(changepoints=None, n_changepoints=25, changepoint_range=0.8, changepoint_prior_scale=0.05, verbose=0, yearly_seasonality=False, weekly_seasonality=False, daily_seasonality=False)Parameter(7)
- 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.- 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. Recommended to take values within [0.001,0.5].
- yearly_seasonality: str or bool or int, default=False
- Include yearly seasonality in the model. “auto” for automatic determination, True to enable, False to disable, or an integer specifying the number of terms to include in the Fourier series.
- weekly_seasonality: str or bool or int, default=False
- Include weekly seasonality in the model. “auto” for automatic determination, True to enable, False to disable, or an integer specifying the number of terms to include in the Fourier series.
- daily_seasonality: str or bool or int, default=False
- Include weekly seasonality in the model. “auto” for automatic determination, True to enable, False to disable, or an integer specifying the number of terms to include in the Fourier series.
Beispiele
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.trend import ProphetPiecewiseLinearTrendForecaster
>>> from sktime.forecasting.base import ForecastingHorizon
>>> from sktime.split import temporal_train_test_split
>>> y = load_airline (). to_timestamp (freq = 'M')
>>> y_train, y_test = temporal_train_test_split (y)
>>> fh = ForecastingHorizon (y. index, is_relative = False)
>>> forecaster = ProphetPiecewiseLinearTrendForecaster ()
>>> forecaster. fit (y_train) ProphetPiecewiseLinearTrendForecaster(
... )
>>> y_pred = forecaster. predict (fh)