Statsmodels Adapters API¶
This section documents adapters for integrating classic
statsmodels time-series models into the eb-adapters package.
All content below is generated automatically from NumPy-style docstrings in the source code.
Statsmodels Adapter Module¶
eb_adapters.statsmodels
¶
SarimaxAdapter
¶
Bases: BaseAdapter
Adapter for statsmodels SARIMAX.
This wrapper fits a univariate SARIMAX model on y and produces forecasts for
len(X) steps ahead when predict(X) is called.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
tuple[int, int, int]
|
ARIMA (p, d, q) order. |
(1, 0, 0)
|
seasonal_order
|
tuple[int, int, int, int]
|
Seasonal (P, D, Q, s) order. |
(0, 0, 0, 0)
|
trend
|
str | None
|
Trend specification forwarded to SARIMAX. |
None
|
enforce_stationarity
|
bool
|
Whether to enforce stationarity in the SARIMAX model. |
True
|
enforce_invertibility
|
bool
|
Whether to enforce invertibility in the SARIMAX model. |
True
|
Notes
Xis ignored during fitting. It is only used at prediction time to determine the forecast horizon (n_steps = len(X)).- This adapter stores initialization parameters via
get_params()so cloning utilities can reconstruct the adapter.
fit(X, y, sample_weight=None)
¶
Fit a univariate SARIMAX model on y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Ignored. Present for API compatibility. |
required |
y
|
ndarray
|
Target series of shape (n_samples,). |
required |
sample_weight
|
ndarray | None
|
Accepted for API compatibility but ignored by this adapter. |
None
|
Returns:
| Type | Description |
|---|---|
SarimaxAdapter
|
The fitted adapter (self), allowing method chaining. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
predict(X)
¶
Forecast len(X) steps ahead from the end of the training sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Array-like placeholder used to determine the forecast horizon. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Forecast values of shape (len(X),). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has not been fit yet. |
get_params(deep=True)
¶
Return initialization parameters for cloning utilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deep
|
bool
|
Included for scikit-learn compatibility. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Initialization parameters that can be passed back to |
set_params(**params)
¶
Update adapter parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**params
|
Any
|
Parameters to set as attributes on the adapter instance. |
{}
|
Returns:
| Type | Description |
|---|---|
SarimaxAdapter
|
The updated adapter instance (self). |
ArimaAdapter
¶
Bases: BaseAdapter
Adapter for statsmodels ARIMA.
This wrapper fits a univariate ARIMA model on y and produces forecasts for
len(X) steps ahead when predict(X) is called.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
tuple[int, int, int]
|
ARIMA (p, d, q) order. |
(1, 0, 0)
|
trend
|
str | None
|
Trend specification forwarded to |
None
|
Notes
Xis ignored during fitting. It is only used at prediction time to determine the forecast horizon (n_steps = len(X)).- This adapter stores initialization parameters via
get_params()so cloning utilities can reconstruct the adapter.
fit(X, y, sample_weight=None)
¶
Fit a univariate ARIMA model on y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Ignored. Present for API compatibility. |
required |
y
|
ndarray
|
Target series of shape (n_samples,). |
required |
sample_weight
|
ndarray | None
|
Accepted for API compatibility but ignored by this adapter. |
None
|
Returns:
| Type | Description |
|---|---|
ArimaAdapter
|
The fitted adapter (self), allowing method chaining. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
predict(X)
¶
Forecast len(X) steps ahead from the end of the training sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
Array-like placeholder used to determine the forecast horizon. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Forecast values of shape (len(X),). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter has not been fit yet. |
get_params(deep=True)
¶
Return initialization parameters for cloning utilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deep
|
bool
|
Included for scikit-learn compatibility. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Initialization parameters that can be passed back to |
set_params(**params)
¶
Update adapter parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**params
|
Any
|
Parameters to set as attributes on the adapter instance. |
{}
|
Returns:
| Type | Description |
|---|---|
ArimaAdapter
|
The updated adapter instance (self). |