Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

IMAPA (Intermittent Multiple Aggregation Prediction Algorithm) — JAX version.

IMAPA

chronax.models.imapa.IMAPA · inherits BaseForecaster

IMAPA is designed for intermittent demand time series — data where many observations are zero or near-zero and demand occurs sporadically. It improves on simple exponential smoothing by: 1. Aggregating the original series at multiple temporal resolutions (levels 1, 2, …, K) to reduce sparsity. 2. Fitting SES independently at each aggregation level. 3. Back-mapping each level's forecast to the original time scale (dividing by the aggregation factor) and averaging across all levels. Point forecasts are designed for parity with StatsForecast.IMAPA. Prediction intervals are conformal (distribution-free), produced via the library's :class:ConformalIntervals machinery.

__init__(self, alias='IMAPA', conformal_params=None)

Initialize the IMAPA estimator configuration.

Parameter Type Default Description
alias str "IMAPA" Display name for the model (used in logging and labels).
conformal_params Optional[ConformalIntervals] None Configuration for conformal prediction intervals. When provided, conformity scores are cached at :meth:fit time so that :meth:predict can emit intervals without recomputation.

fit(self, y, X=None) -> Self

Fit IMAPA to a univariate time series.

Aggregates y at multiple temporal levels, fits SES at each level, and stores the resulting model state in :attr:model_. If conformal_params was provided at construction, conformity scores are also computed and cached so that :meth:predict can emit intervals without re-fitting.

Parameter Type Default Description
y jnp.ndarray - One-dimensional time series of shape (n,).
X Optional[jnp.ndarray] None Ignored — present for API compatibility with :class:BaseForecaster.

Returns: Self (the fitted forecaster; sets self.model_).

predict(self, h, X=None, level=None) -> dict

Forecast h steps ahead using the fitted IMAPA state.

SES produces flat multi-step forecasts — every future step equals the same scalar value stored in model_["mean"].

Parameter Type Default Description
h int - Forecast horizon (number of future steps).
X Optional[jnp.ndarray] None Ignored — present for API compatibility.
level Optional[List[int]] None Confidence levels in [0, 100] for conformal prediction intervals. Requires that the model was constructed with conformal_params and that :meth:fit has been called.

Returns: dict ({"mean": jnp.ndarray} of shape (h,). When level is provided, also contains "lo-{level}" and "hi-{level}" keys for each requested confidence level.) Raises: ValueError (If called before :meth:fit, or if level is provided without cached conformity scores.)

predict_in_sample(self, level=None) -> dict

Return in-sample fitted values (and optional prediction intervals).

Re-runs the IMAPA aggregation/back-mapping pipeline with fitted=True to produce one-step-ahead fitted values for the training data. Early indices may be NaN due to insufficient aggregation history.

| Parameter | Type | Default | Description | |-----------|---------------|-------------| | level | Optional[List[int]] | None | Confidence levels in [0, 100]. When provided, symmetric ±z·σ intervals are appended around the fitted values. |

Returns: dict ({"fitted": jnp.ndarray} of shape (n,). When level is provided, also contains "fitted-lo-{level}" and "fitted-hi-{level}" keys.)

forecast(self, y, h, X=None, X_future=None, level=None, fitted=False) -> dict

Stateless fit-and-predict in a single call.

Equivalent to calling :meth:fit followed by :meth:predict, but no persistent model state is stored on the instance. This is ideal for cross-validation loops and batch evaluation pipelines.

Parameter Type Default Description
y jnp.ndarray - One-dimensional time series of shape (n,).
h int - Forecast horizon.
X Optional[jnp.ndarray] None Ignored — present for API compatibility.
X_future Optional[jnp.ndarray] None Ignored — present for API compatibility.
level Optional[List[int]] None Confidence levels in [0, 100] for conformal prediction intervals. Requires conformal_params to have been set at construction time.
fitted bool False If True, the returned dict also includes "fitted" (in-sample one-step-ahead predictions of shape (n,)).

Returns: dict (Always contains "mean" of shape (h,). Optionally "fitted" (shape (n,)), "lo-{level}", "hi-{level}", "fitted-lo-{level}", and "fitted-hi-{level}" when level and/or fitted are set.) Raises: Exception (If level is provided but conformal_params was not set.)