CrostonClassic
chronax.croston_classic.CrostonClassic · inherits BaseForecaster
Croston's Classic method for intermittent demand time series.
Suitable for series with many zero values and occasional non-zero demand. Uses SES (α=0.1) to forecast both demand size and inter-demand intervals.
Key Features: - Handles sparse/intermittent data (many zeros) - Fixed smoothing parameter α=0.1 (Croston's original specification) - Decomposes series into demand size and demand intervals - Conformal prediction intervals supported
Note: Only conformal intervals are supported (no native parametric intervals).
__init__(self, alias='CrostonClassic', conformal_params=None)
Initializes the CrostonClassic model.
| Parameter | Type | Default | Description |
|---|---|---|---|
| alias | str | "CrostonClassic" | Model name. |
| conformal_params | Optional[ConformalIntervals] | None | Configuration for conformal prediction intervals. |
fit(self, y, X=None) -> Self
Fit Croston Classic model to time series.
| Parameter | Type | Default | Description |
|---|---|---|---|
| y | jnp.ndarray | - | Time series of shape (t,). |
| X | Optional[jnp.ndarray] | None | Unused (no exogenous support). |
Returns: Self (the fitted forecaster; sets self.model_).
predict(self, h, X=None, level=None) -> Dict[str, jnp.ndarray]
Generate forecasts using fitted model.
| Parameter | Type | Default | Description |
|---|---|---|---|
| h | int | - | Forecast horizon. |
| X | Optional[jnp.ndarray] | None | Unused (no exogenous support). |
| level | Optional[List[int]] | None | Confidence levels for prediction intervals (0-100). |
Returns: dict (Dictionary with 'mean' and optional interval keys ('lo-XX', 'hi-XX')).
predict_in_sample(self, level=None) -> Dict[str, jnp.ndarray]
Access fitted (in-sample) predictions.
Note: Native (parametric) fitted intervals are supported using residual std error.
| Parameter | Type | Default | Description |
|---|---|---|---|
| level | Optional[List[int]] | None | Confidence levels for fitted intervals (0-100). |
Returns: dict (Dictionary with 'fitted' and optional interval keys).
forecast(self, y, h, X=None, X_future=None, level=None, fitted=False) -> Dict[str, jnp.ndarray]
Memory-efficient forecast without storing model state.
Equivalent to fit().predict() but avoids object storage overhead. Useful for one-shot forecasting or cross-validation loops.
| Parameter | Type | Default | Description |
|---|---|---|---|
| y | jnp.ndarray | - | Time series of shape (t,). |
| h | int | - | Forecast horizon. |
| X | Optional[jnp.ndarray] | None | Unused (no exogenous support). |
| X_future | Optional[jnp.ndarray] | None | Unused (no exogenous support). |
| level | Optional[List[int]] | None | Confidence levels for prediction intervals (0-100). |
| fitted | bool | False | Whether to return in-sample fitted values. |
Returns: dict (Dictionary with 'mean', optional 'fitted', and interval keys).