Skip to content

ProphetPiecewiseLinearTrendForecaster

ProphetPiecewiseLinearTrendForecaster

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

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

Parameters:
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 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: 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 changepoints is 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.

Attributes:
cutoff

Cut-off = “present time” state of forecaster.

fh

Forecasting horizon that was passed.

is_fitted

Whether fit has been called.

state

State of the estimator.

References

Examples

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

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.