Docs /Templates/ sinapsis-sktime

AutoARIMASKTimeWrapper

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

AutoARIMA — inherited documentation

Auto-(S)ARIMA(X) forecaster, from pmdarima package.

Includes automated fitting of (S)ARIMA(X) hyper-parameters (p, d, q, P, D, Q).

Exposes ``pmdarima.arima.AutoARIMA`` [1]_ under the ``sktime`` interface. Seasonal ARIMA models and exogenous input is supported, hence this estimator is capable of fitting auto-SARIMA, auto-ARIMAX, and auto-SARIMAX.

The auto-ARIMA algorithm seeks to identify the most optimal parameters for an ARIMA model, settling on a single fitted ARIMA model. This process is based on the commonly-used R function, forecast::auto.arima.

Auto-ARIMA works by conducting differencing tests (i.e., Kwiatkowski-Phillips-Schmidt-Shin, Augmented Dickey-Fuller or Phillips-Perron) to determine the order of differencing, d, and then fitting models within ranges of defined start_p, max_p, start_q, max_q ranges. If the seasonal optional is enabled, auto-ARIMA also seeks to identify the optimal P and Q hyper-parameters after conducting the Canova-Hansen to determine the optimal order of seasonal differencing, D.

In order to find the best model, auto-ARIMA optimizes for a given information_criterion, one of ('aic', 'aicc', 'bic', 'hqic', 'oob') (Akaike Information Criterion, Corrected Akaike Information Criterion, Bayesian Information Criterion, Hannan-Quinn Information Criterion, or "out of bag"-for validation scoring-respectively) and returns the ARIMA which minimizes the value.

Note that due to stationarity issues, auto-ARIMA might not find a suitable model that will converge. If this is the case, a ValueError will be thrown suggesting stationarity-inducing measures be taken prior to re-fitting or that a new range of order values be selected. Non- stepwise (i.e., essentially a grid search) selection can be slow, especially for seasonal data. Stepwise algorithm is outlined in Hyndman and Khandakar (2008).

Parameters ---------- start_p : int, optional (default=2) The starting value of p, the order (or number of time lags) of the auto-regressive ("AR") model. Must be a positive integer. d : int, optional (default=None) The order of first-differencing. If None (by default), the value will automatically be selected based on the results of the test (i.e., either the Kwiatkowski-Phillips-Schmidt-Shin, Augmented Dickey-Fuller or the Phillips-Perron test will be conducted to find the most probable value). Must be a positive integer or None. Note that if d is None, the runtime could be significantly longer. start_q : int, optional (default=2) The starting value of q, the order of the moving-average ("MA") model. Must be a positive integer. max_p : int, optional (default=5) The maximum value of p, inclusive. Must be a positive integer greater than or equal to start_p. max_d : int, optional (default=2) The maximum value of d, or the maximum number of non-seasonal differences. Must be a positive integer greater than or equal to d. max_q : int, optional (default=5) he maximum value of q, inclusive. Must be a positive integer greater than start_q. start_P : int, optional (default=1) The starting value of P, the order of the auto-regressive portion of the seasonal model. D : int, optional (default=None) The order of the seasonal differencing. If None (by default, the value will automatically be selected based on the results of the seasonal_test. Must be a positive integer or None. start_Q : int, optional (default=1) The starting value of Q, the order of the moving-average portion of the seasonal model. max_P : int, optional (default=2) The maximum value of P, inclusive. Must be a positive integer greater than start_P. max_D : int, optional (default=1) The maximum value of D. Must be a positive integer greater than D. max_Q : int, optional (default=2) The maximum value of Q, inclusive. Must be a positive integer greater than start_Q. max_order : int, optional (default=5) Maximum value of p+q+P+Q if model selection is not stepwise. If the sum of p and q is >= max_order, a model will not be fit with those parameters, but will progress to the next combination. Default is 5. If max_order is None, it means there are no constraints on maximum order. sp : int, optional (default=1) The period for seasonal differencing, sp refers to the number of periods in each season. For example, sp is 4 for quarterly data, 12 for monthly data, or 1 for annual (non-seasonal) data. Default is 1. Note that if sp == 1 (i.e., is non-seasonal), seasonal will be set to False. For more information on setting this parameter, see Setting sp. (link to http://alkaline-ml.com/pmdarima/tips_and_tricks.html#period) seasonal : bool, optional (default=True) Whether to fit a seasonal ARIMA. Default is True. Note that if seasonal is True and sp == 1, seasonal will be set to False. stationary : bool, optional (default=False) Whether the time-series is stationary and d should be set to zero. information_criterion : str, optional (default='aic') The information criterion used to select the best ARIMA model. One of pmdarima.arima.auto_arima.VALID_CRITERIA, ('aic', 'bic', 'hqic', 'oob'). alpha : float, optional (default=0.05) Level of the test for testing significance. test : str, optional (default='kpss') Type of unit root test to use in order to detect stationarity if stationary is False and d is None. seasonal_test : str, optional (default='ocsb') This determines which seasonal unit root test is used if seasonal is True and D is None. stepwise : bool, optional (default=True) Whether to use the stepwise algorithm outlined in Hyndman and Khandakar (2008) to identify the optimal model parameters. The stepwise algorithm can be significantly faster than fitting all (or a random subset of) hyper-parameter combinations and is less likely to over-fit the model. n_jobs : int, optional (default=1) The number of models to fit in parallel in the case of a grid search (stepwise=False). Default is 1, but -1 can be used to designate "as many as possible". start_params : array-like, optional (default=None) Starting parameters for ARMA(p,q). If None, the default is given by ARMA._fit_start_params. trend : str, optional (default=None) The trend parameter. If with_intercept is True, trend will be used. If with_intercept is False, the trend will be set to a no- intercept value. method : str, optional (default='lbfgs') The ``method`` determines which solver from ``scipy.optimize`` is used, and it can be chosen from among the following strings:

- 'newton' for Newton-Raphson - 'nm' for Nelder-Mead - 'bfgs' for Broyden-Fletcher-Goldfarb-Shanno (BFGS) - 'lbfgs' for limited-memory BFGS with optional box constraints - 'powell' for modified Powell's method - 'cg' for conjugate gradient - 'ncg' for Newton-conjugate gradient - 'basinhopping' for global basin-hopping solver

The explicit arguments in ``fit`` are passed to the solver, with the exception of the basin-hopping solver. Each solver has several optional arguments that are not the same across solvers. These can be passed as **fit_kwargs maxiter : int, optional (default=50) The maximum number of function evaluations. offset_test_args : dict, optional (default=None) The args to pass to the constructor of the offset (d) test. See pmdarima.arima.stationarity for more details. seasonal_test_args : dict, optional (default=None) The args to pass to the constructor of the seasonal offset (D) test. See pmdarima.arima.seasonality for more details. suppress_warnings : bool, optional (default=False) Many warnings might be thrown inside of statsmodels. If suppress_warnings is True, all of the warnings coming from ARIMA will be squelched. error_action : str, optional (default='warn') If unable to fit an ARIMA due to stationarity issues, whether to warn ('warn'), raise the ValueError ('raise') or ignore ('ignore'). Note that the default behavior is to warn, and fits that fail will be returned as None. This is the recommended behavior, as statsmodels ARIMA and SARIMAX models hit bugs periodically that can cause an otherwise healthy parameter combination to fail for reasons not related to pmdarima. trace : bool, optional (default=False) Whether to print status on the fits. A value of False will print no debugging information. A value of True will print some. Integer values exceeding 1 will print increasing amounts of debug information at each fit. random : bool, optional (default='False') Similar to grid searches, auto_arima provides the capability to perform a "random search" over a hyper-parameter space. If random is True, rather than perform an exhaustive search or stepwise search, only n_fits ARIMA models will be fit (stepwise must be False for this option to do anything). random_state : int, long or numpy RandomState, optional (default=None) The PRNG for when random=True. Ensures replicable testing and results. n_fits : int, optional (default=10) If random is True and a "random search" is going to be performed, n_iter is the number of ARIMA models to be fit. out_of_sample_size : int, optional (default=0) The number of examples from the tail of the time series to hold out and use as validation examples. The model will not be fit on these samples, but the observations will be added into the model's ``endog`` and ``exog`` arrays so that future forecast values originate from the end of the endogenous vector. For instance:: y = [0, 1, 2, 3, 4, 5, 6] out_of_sample_size = 2 > Fit on: [0, 1, 2, 3, 4] > Score on: [5, 6] > Append [5, 6] to end of self.arima_res_.data.endog values scoring : str, optional (default='mse') If performing validation (i.e., if out_of_sample_size > 0), the metric to use for scoring the out-of-sample data. One of ('mse', 'mae') scoring_args : dict, optional (default=None) A dictionary of key-word arguments to be passed to the scoring metric. with_intercept : bool, optional (default=True) Whether to include an intercept term. update_pdq : bool, optional (default=True) whether to update pdq parameters in update True: model is refit on all data seen so far, potentially updating p,d,q False: model updates only ARIMA coefficients via likelihood, as in pmdarima time_varying_regression : boolean, optional (default=False) Whether or not coefficients on the exogenous regressors are allowed to vary over time. enforce_stationarity : boolean, optional (default=True) Whether or not to transform the AR parameters to enforce stationarity in the auto-regressive component of the model. - enforce_invertibility : boolean, optional (default=True) Whether or not to transform the MA parameters to enforce invertibility in the moving average component of the model. simple_differencing : boolean, optional (default=False) Whether or not to use partially conditional maximum likelihood estimation for seasonal ARIMA models. If True, differencing is performed prior to estimation, which discards the first :math:`s D + d` initial rows but results in a smaller state-space formulation. If False, the full SARIMAX model is put in state-space form so that all datapoints can be used in estimation. Default is False. measurement_error: boolean, optional (default=False) Whether or not to assume the endogenous observations endog were measured with error. Default is False. mle_regression : boolean, optional (default=True) Whether or not to use estimate the regression coefficients for the exogenous variables as part of maximum likelihood estimation or through the Kalman filter (i.e. recursive least squares). If time_varying_regression is True, this must be set to False. Default is True.

hamilton_representation : boolean, optional (default=False) Whether or not to use the Hamilton representation of an ARMA process

* if True, uses the Hamilton representation. * if False, uses the Harvey representation.

Default is False.

concentrate_scale : boolean, optional (default=False) Whether or not to concentrate the scale out of the likelihood, scale = variance of the error term. This reduces the number of parameters estimated by maximum likelihood by one, but standard errors will then not be available for the scale parameter.

See Also -------- ARIMA StatsForecastAutoARIMA

References ---------- .. [1] https://alkaline-ml.com/pmdarima/modules/generated/pmdarima.arima.AutoARIMA.html

Examples -------- >>> from sktime.datasets import load_airline >>> from sktime.forecasting.arima import AutoARIMA >>> y = load_airline() >>> forecaster = AutoARIMA( ... sp=12, d=0, max_p=2, max_q=2, suppress_warnings=True ... ) # doctest: +SKIP >>> forecaster.fit(y) # doctest: +SKIP AutoARIMA(...) >>> y_pred = forecaster.predict(fh=[1,2,3]) # doctest: +SKIP

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. autoarima_init start_p <class 'int'>: default: 2 d typing.Optional[int]: default: None start_q <class 'int'>: default: 2 max_p <class 'int'>: default: 5 max_d <class… Read full field description

Number of steps ahead to forecast. Defaults to 37. autoarima_init start_p <class 'int'>: default: 2 d typing.Optional[int]: default: None start_q <class 'int'>: default: 2 max_p <class 'int'>: default: 5 max_d <class 'int'>: default: 2 max_q <class 'int'>: default: 5 start_P <class 'int'>: default: 1 D typing.Optional[int]: default: None start_Q <class 'int'>: default: 1 max_P <class 'int'>: default: 2 max_D <class 'int'>: default: 1 max_Q <class 'int'>: default: 2 max_order <class 'int'>: default: 5 sp <class 'int'>: default: 1 seasonal <class 'bool'>: default: True stationary <class 'bool'>: default: False information_criterion <class 'str'>: default: aic alpha <class 'float'>: default: 0.05 test <class 'str'>: default: kpss seasonal_test <class 'str'>: default: ocsb stepwise <class 'bool'>: default: True n_jobs <class 'int'>: default: 1 start_params <class 'NoneType'>: default: None trend typing.Optional[str]: default: None method <class 'str'>: default: lbfgs maxiter <class 'int'>: default: 50 offset_test_args typing.Optional[dict]: default: None seasonal_test_args typing.Optional[dict]: default: None suppress_warnings <class 'bool'>: default: False error_action <class 'str'>: default: warn trace <class 'bool'>: default: False random <class 'bool'>: default: False random_state typing.Optional[int]: default: None n_fits <class 'int'>: default: 10 out_of_sample_size <class 'int'>: default: 0 scoring <class 'str'>: default: mse scoring_args typing.Optional[dict]: default: None with_intercept <class 'bool'>: default: True update_pdq <class 'bool'>: default: True time_varying_regression <class 'bool'>: default: False enforce_stationarity <class 'bool'>: default: True simple_differencing <class 'bool'>: default: False measurement_error <class 'bool'>: default: False mle_regression <class 'bool'>: default: True hamilton_representation <class 'bool'>: default: False concentrate_scale <class 'bool'>: default: False

int
Optional
Default: 37
autoarima_initRequired
AutoARIMAAttributes
Required
Default: null
D
typing.Optional[int]
Optional
Default: null
d
typing.Optional[int]
Optional
Default: null
sp
int
Optional
Default: 1
test
str
Optional
Default: "kpss"
alpha
float
Optional
Default: 0.05
max_D
int
Optional
Default: 1
max_P
int
Optional
Default: 2
max_Q
int
Optional
Default: 2
max_d
int
Optional
Default: 2
max_p
int
Optional
Default: 5
max_q
int
Optional
Default: 5
trace
bool
Optional
Default: false
trend
typing.Optional[str]
Optional
Default: null
method
str
Optional
Default: "lbfgs"
n_fits
int
Optional
Default: 10
n_jobs
int
Optional
Default: 1
random
bool
Optional
Default: false
maxiter
int
Optional
Default: 50
scoring
str
Optional
Default: "mse"
start_P
int
Optional
Default: 1
start_Q
int
Optional
Default: 1
start_p
int
Optional
Default: 2
start_q
int
Optional
Default: 2
seasonal
bool
Optional
Default: true
stepwise
bool
Optional
Default: true
max_order
int
Optional
Default: 5
stationary
bool
Optional
Default: false
update_pdq
bool
Optional
Default: true
error_action
str
Optional
Default: "warn"
random_state
typing.Optional[int]
Optional
Default: null
scoring_args
typing.Optional[dict]
Optional
Default: null
start_params
NoneType
Optional
Default: null
seasonal_test
str
Optional
Default: "ocsb"
mle_regression
bool
Optional
Default: true
with_intercept
bool
Optional
Default: true
offset_test_args
typing.Optional[dict]
Optional
Default: null
concentrate_scale
bool
Optional
Default: false
measurement_error
bool
Optional
Default: false
suppress_warnings
bool
Optional
Default: false
out_of_sample_size
int
Optional
Default: 0
seasonal_test_args
typing.Optional[dict]
Optional
Default: null
simple_differencing
bool
Optional
Default: false
enforce_stationarity
bool
Optional
Default: true
information_criterion
str
Optional
Default: "aic"
hamilton_representation
bool
Optional
Default: false
time_varying_regression
bool
Optional
Default: false
model_save_pathRequired
str
Required
Default: null

Configuration example

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

yaml
templates:
  - template_name: "AutoARIMASKTimeWrapper"
    class_name: "AutoARIMASKTimeWrapper"
    attributes:
      root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
      n_steps_ahead: 37
      autoarima_init:
        D: null
        d: null
        sp: 1
        test: "kpss"
        alpha: 0.05
        max_D: 1
        max_P: 2
        max_Q: 2
        max_d: 2
        max_p: 5
        max_q: 5
        trace: false
        trend: null
        method: "lbfgs"
        n_fits: 10
        n_jobs: 1
        random: false
        maxiter: 50
        scoring: "mse"
        start_P: 1
        start_Q: 1
        start_p: 2
        start_q: 2
        seasonal: true
        stepwise: true
        max_order: 5
        stationary: false
        update_pdq: true
        error_action: "warn"
        random_state: null
        scoring_args: null
        start_params: null
        seasonal_test: "ocsb"
        mle_regression: true
        with_intercept: true
        offset_test_args: null
        concentrate_scale: false
        measurement_error: false
        suppress_warnings: false
        out_of_sample_size: 0
        seasonal_test_args: null
        simple_differencing: false
        enforce_stationarity: true
        information_criterion: "aic"
        hamilton_representation: false
        time_varying_regression: false
      model_save_path: "<required>"

Inheritance

Immediate parent: sinapsis_sktime.templates.sktime_forecasters.SKTimeArimaForecaster

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere