Back to models
Forecaster

TrendForecaster

Categorical featuresIn-sample predictionsIn-sample prediction intervals

Trend based forecasts of time series data, regressing values on index.

Uses an sklearn regressor specified by the regressor parameter to perform regression on time series values against their corresponding indices, providing trend-based forecasts:

In fit, for input time series \((v_i, t_i), i = 1, \dots, T\), where \(v_i\) are values and \(t_i\) are time stamps, fits an sklearn model \(v_i = f(t_i) + \epsilon_i\), where \(f\) is the model fitted when regressor.fit is passed X = vector of \(t_i\), and y = vector of \(v_i\).

In predict, for a new time point \(t_*\), predicts \(f(t_*)\), where \(f\) is the function as fitted above in fit.

Default for regressor is linear regression = sklearn LinearRegression, with default parameters.

If time stamps are pd.DatetimeIndex, fitted coefficients are in units of days since start of 1970. If time stamps are pd.PeriodIndex, coefficients are in units of (full) periods since start of 1970.

Quickstart

python
from sktime.forecasting.trend import TrendForecaster

estimator = TrendForecaster(regressor=None)

Tags

Capabilities

  • Categorical features
  • In-sample predictions: Supported
  • In-sample prediction intervals: Supported
  • Prediction intervals: Not supported
  • Missing values: Not supported
  • Exogenous variables: Not supported
  • Multivariate: Not supported

Properties

Needs forecast horizon in fitrequires-fh-in-fit
No
X and y need the same indexX-y-must-have-same-index
Yes

Parameters(1)

regressorestimator object, default = None
Define the regression model type. If not set, will default to

sklearn.linear_model.LinearRegression

Examples

>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.trend import TrendForecaster
>>> y = load_airline ()
>>> forecaster = TrendForecaster ()
>>> forecaster. fit (y) TrendForecaster(
... )
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])