Docs /Templates/ sinapsis-sktime

NaiveVarianceSKTimeWrapper

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

NaiveVariance — inherited documentation

Compute the prediction variance based on a naive strategy.

NaiveVariance adds to a ``forecaster`` the ability to compute the prediction variance based on naive assumptions about the time series. The simple strategy is as follows: - Let :math:`y_1,\dots,y_T` be the time series we fit the estimator :math:`f` to. - Let :math:`\widehat{y}_{ij}` be the forecast for time point :math:`j`, obtained from fitting the forecaster to the partial time series :math:`y_1,\dots,y_i`. - We compute the residuals matrix :math:`R=(r_{ij})=(y_j-\widehat{y}_{ij})`. - The variance prediction :math:`v_k` for :math:`y_{T+k}` is :math:`\frac{1}{T-k}\sum_{i=1}^{T-k} a_{i,i+k}^2` because we are averaging squared residuals of all forecasts that are :math:`k` time points ahead. - And for the covariance matrix prediction, the formula becomes :math:`Cov(y_k, y_l)=\frac{\sum_{i=1}^N \hat{r}_{k,k+i}*\hat{r}_{l,l+i}}{N}`.

The resulting forecaster will implement ``predict_interval``, ``predict_quantiles``, ``predict_var``, and ``predict_proba``, even if the wrapped forecaster ``forecaster`` did not have this capability; for point forecasts (``predict``), behaves like the wrapped forecaster.

Parameters ---------- forecaster : estimator Estimator to which probabilistic forecasts are being added initial_window : int, optional, default=1 number of minimum initial indices to use for fitting when computing residuals verbose : bool, optional, default=False whether to print warnings if windows with too few data points occur

Examples -------- >>> from sktime.datasets import load_airline >>> from sktime.forecasting.naive import NaiveForecaster, NaiveVariance >>> y = load_airline() >>> forecaster = NaiveForecaster(strategy="drift") >>> variance_forecaster = NaiveVariance(forecaster) >>> variance_forecaster.fit(y) NaiveVariance(...) >>> var_pred = variance_forecaster.predict_var(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. naivevariance_init forecaster <class 'type'>: default: <class 'inspect._empty'> initial_window <class 'int'>: default: 1 verbose <class 'bool'>: default: False

int
Optional
Default: 37
model_save_pathRequired
str
Required
Default: null
naivevariance_initRequired
NaiveVarianceAttributes
Required
Default: null
verbose
bool
Optional
Default: false
forecaster
type
Optional
Default: null
initial_window
int
Optional
Default: 1

Configuration example

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

yaml
templates:
  - template_name: "NaiveVarianceSKTimeWrapper"
    class_name: "NaiveVarianceSKTimeWrapper"
    attributes:
      root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
      n_steps_ahead: 37
      model_save_path: "<required>"
      naivevariance_init:
        verbose: false
        forecaster: {}
        initial_window: 1

Inheritance

Immediate parent: sinapsis_sktime.templates.sktime_forecasters.SKTimeNaiveForecaster

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere