Docs /Templates/ sinapsis-sktime

PolynomialTrendForecasterSKTimeWrapper

sinapsis-sktimeSKTimedynamicinferencemodelsprediction

Python template · sinapsis_sktime.templates.sktime_forecasters

Overview

This template specifically handles sktime series forecasting tasks.

The goal is to train a model and predict future values of the input time series.

Attributes: WrapperEntry (WrapperEntryConfig): Configuration for dynamic template generation TASK_TYPE (str): The type of task (forecasting) CATEGORY (str): The category of the template AttributesBaseModel: Reference to the attributes' model class

PolynomialTrendForecaster — inherited documentation

Forecast time series data with a polynomial trend.

Uses an ``sklearn`` regressor specified by the ``regressor`` parameter to perform regression on time series values against their corresponding indices, after extraction of polynomial features. Same as ``TrendForecaster`` where ``regressor`` is pipelined with transformation step ``PolynomialFeatures(degree, with_intercept)`` applied to time index, at the start.

In ``fit``, for input time series :math:`(v_i, p(t_i)), i = 1, \dots, T`, where :math:`v_i` are values, :math:`t_i` are time stamps, and :math:`p` is the polynomial feature transform with degree ``degree``, and with/without intercept depending on ``with_intercept``, fits an ``sklearn`` model :math:`v_i = f(p(t_i)) + \epsilon_i`, where :math:`f` is the model fitted when ``regressor.fit`` is passed ``X`` = vector of :math:`p(t_i)`, and ``y`` = vector of :math:`v_i`.

In ``predict``, for a new time point :math:`t_*`, predicts :math:`f(p(t_*))`, where :math:`f` is the function as fitted above in ``fit``, and :math:`p` is the same polynomial feature transform as above.

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

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.

Parameters ---------- regressor : sklearn regressor estimator object, default = None Define the regression model type. If not set, will default to sklearn.linear_model.LinearRegression degree : int, default = 1 Degree of polynomial function with_intercept : bool, default=True If true, then include a feature in which all polynomial powers are zero. (i.e. a column of ones, acts as an intercept term in a linear model) prediction_intervals : bool, default=False Whether to compute prediction intervals. If True, additional calculations are done during fit to enable prediction intervals to be calculated during predict. The prediction intervals are calculated according to Section 7.9 in [1]. The formulas are standard and are based on an OLS regression model fitted to the data. The formulas in [1] assume a regression with intercept and are modified appropriately if with_intercept is False.

Attributes ---------- regressor_ : sklearn regressor estimator object The fitted regressor object. This is a fitted ``sklearn`` pipeline with steps ``PolynomialFeatures(degree, with_intercept)``, followed by a clone of ``regressor``.

References ---------- .. [1] Hyndman, Rob J., and George Athanasopoulos. Forecasting: principles and practice, 3rd edition. OTexts: Melbourne, Australia. OTexts.com/fpp3.

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

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-sktime==1.0.0
uv pip install sinapsis-sktime==1.0.0
uv add sinapsis-sktime==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
root_dir
str
Optional
Default: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
n_steps_ahead

Number of steps ahead to forecast. Defaults to 37. polynomialtrendforecaster_init regressor <class 'NoneType'>: default: None degree <class 'int'>: default: 1 with_intercept <class 'bool'>: default: True prediction_intervals <class 'bool'>: default: False

int
Optional
Default: 37
model_save_pathRequired
str
Required
Default: null
polynomialtrendforecaster_initRequired
PolynomialTrendForecasterAttributes
Required
Default: null
degree
int
Optional
Default: 1
regressor
NoneType
Optional
Default: null
with_intercept
bool
Optional
Default: true
prediction_intervals
bool
Optional
Default: false

Configuration example

Generated from documented defaults. Replace any placeholders and complete required nested settings before running.

yaml
templates:
  - template_name: "PolynomialTrendForecasterSKTimeWrapper"
    class_name: "PolynomialTrendForecasterSKTimeWrapper"
    attributes:
      root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
      n_steps_ahead: 37
      model_save_path: "<required>"
      polynomialtrendforecaster_init:
        degree: 1
        regressor: null
        with_intercept: true
        prediction_intervals: false

Inheritance

Immediate parent: sinapsis_sktime.templates.sktime_forecasters.SKTimeTrendForecaster

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere