Zurück zu den Modellen
Forecaster

SplineTrendForecaster

Categorical in XInsamplePred int insample

Forecast time series data with a spline trend.

Uses an sklearn regressor specified by the regressor parameter to perform regression on time series values against their corresponding indices, after transformation of the indices with SplineTransformer.

Schnellstart

python
from sktime.forecasting.trend import SplineTrendForecaster

estimator = SplineTrendForecaster(regressor=None, n_knots=5, degree=1, knots='uniform', extrapolation='constant', with_intercept=True)

Parameter(7)

regressorsklearn regressor estimator object, default=None

Define the regression model type. If not set, defaults to sklearn.linear_model.LinearRegression.

n_knotsint, default=5

Number of knots of the splines if knots is one of {‘uniform’, ‘quantile’}. Must be at least 2. Ignored if knots is array-like.

degreeint, default=1
Degree of the splines (1 for linear, 2 for quadratic, etc.).
n_knotsint, default=4
Number of knots for the spline transformation.
knots{‘uniform’, ‘quantile’}or array-like of shape (n_knots, n_features),

default=’uniform’ Determines knot positions such that first knot <= features <= last knot.

  • ‘uniform’: n_knots are distributed uniformly between the

min and max values of the features. - ‘quantile’: n_knots are distributed uniformly along the quantiles of the features. - array-like: Specifies sorted knot positions, including the boundary knots. Internally, additional knots are added before the first knot and after the last knot based on the spline degree.

extrapolation{‘error’, ‘constant’, ‘linear’, ‘continue’, ‘periodic’},

default=’constant’ Determines how to handle values outside the min and max values of the training features:

  • ‘error’: Raises a ValueError.

  • ‘constant’: Uses the spline value at the minimum or maximum feature as

constant extrapolation. - ‘linear’: Applies linear extrapolation. - ‘continue’: Extrapolates as is (equivalent to extrapolate=True in scipy.interpolate.BSpline). - ‘periodic’: Uses periodic splines with a periodicity equal to the distance between the first and last knot, enforcing equal function values and derivatives at these knots.

with_interceptbool, default=True
If True, includes a feature in which all polynomial powers are zero (i.e., a column of ones, acting as an intercept term in a linear model).

Beispiele

>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.trend import SplineTrendForecaster
>>> y = load_airline ()
>>> forecaster = SplineTrendForecaster (
... n_knots = 5,
... degree = 2,
... knots = "uniform",
... extrapolation = "constant"
... )
>>> forecaster. fit (y) SplineTrendForecaster(
... )
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])