core module

class core.GeneralAutoRegressor(base_estimator, auto_order, exog_order, exog_delay=None, pred_step=1, **base_params)[source]

Bases: core.TimeSeriesRegressor, sklearn.base.RegressorMixin

The general auto regression model can be written in the following form:

(1)\[\begin{split}y(t + k) &=& f(y(t), ..., y(t-p+1), \\ & & x_1(t - d_1), ..., x_1(t-d_1-q_1+1), \\ & & ..., x_m(t - d_1), ..., x_m(t - d_m - q_m + 1)) + e(t)\end{split}\]
Parameters:
  • base_estimator (object) – an estimator object that implements the scikit-learn API (fit, and predict). The estimator will be used to fit the function \(f\) in equation (1).
  • auto_order (int) – the autoregression order \(p\) in equation (1).
  • exog_order (list) – the exogenous input order, a list of integers representing the order for each exogenous input, i.e. \([q_1, q_2, ..., q_m]\) in equation (1).
  • exog_delay (list) – the delays of the exogenous inputs, a list of integers representing the delay of each exogenous input, i.e. \([d_1, d_2, ..., d_m]\) in equation (1). By default, all the delays are set to 0.
  • pred_step (int) – the prediction step \(k\) in equation (1). By default, it is set to 1.
  • base_params (dict) – other keyword arguments for base_estimator.
fit(X, y, **params)[source]

Create lag features and fit the base_estimator.

Parameters:
  • X (array-like) – exogenous input time series, shape = (n_samples, n_exog_inputs)
  • y (array-like) – target time series to predict, shape = (n_samples)

Perform grid search on the base_estimator. The function first generates the lag features and predicting targets, and then calls GridSearchCV in scikit-learn package.

Parameters:
  • X (array-like) – exogenous input time series, shape = (n_samples, n_exog_inputs)
  • y (array-like) – target time series to predict, shape = (n_samples)
  • para_grid (dict) – use the same format in GridSearchCV in scikit-learn package.
  • params (dict) – other keyword arguments that can be passed into GridSearchCV in scikit-learn package.
class core.TimeSeriesRegressor(base_estimator, **base_params)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.RegressorMixin

TimeSeriesRegressor creates a time series model based on a general-purpose regression model defined in base_estimator. base_estimator must be a model which implements the scikit-learn APIs.

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

**params : dict
Estimator parameters.
self : object
Estimator instance.