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.

Forecast a univariate series using AutoARIMA

Use this guide to initialize, fit, and predict future values for a single time series using the automated ARIMA model implementation in Chronax. This is the standard starting point for time series forecasting.

Prerequisites

  • You have installed Chronax and its dependencies (JAX).
  • The target series y must be a 1-D jnp.ndarray of type float32.
import jax.numpy as jnp
from chronax.models import AutoARIMA

Steps

1. Prepare the input data

Chronax models operate on JAX arrays. Define your historical time series data, ensuring it is a 1-D array of float32.

# Historical data (e.g., 100 observations)
y = jnp.array([
    10.1, 10.5, 10.3, 10.9, 11.2, 11.5, 11.0, 11.8, 12.0, 12.5
] * 10, dtype=jnp.float32)

2. Initialize the AutoARIMA model

Instantiate the AutoARIMA model. This model automatically searches for the optimal ARIMA order (p, d, q) based on the input data during the fitting process.

model = AutoARIMA()

3. Fit the model to the historical data

Call the fit method, passing the historical series y. The model learns its internal parameters and determines the best structure based on this data.

params = model.fit(y)

4. Predict future steps

Use the predict method to generate forecasts for a specified horizon h. The result is a dictionary containing the forecast mean and potentially other metrics.

# Define the forecast horizon (e.g., 12 steps ahead)
h = 12

# Generate the forecast
out = model.predict(h)

# Access the mean forecast array
mean_forecast = out["mean"]

print(f"Forecast shape: {mean_forecast.shape}")

Full example

This complete example demonstrates the end-to-end workflow for univariate forecasting.

import jax.numpy as jnp
from chronax.models import AutoARIMA

# 1. Prepare data (100 observations)
y = jnp.array([
    10.1, 10.5, 10.3, 10.9, 11.2, 11.5, 11.0, 11.8, 12.0, 12.5
] * 10, dtype=jnp.float32)

# 2. Initialize the model
model = AutoARIMA()

# 3. Fit the model
params = model.fit(y)

# 4. Predict future steps (h=12)
h = 12
out = model.predict(h)

# Print results
print("Historical data length:", len(y))
print("Forecast length:", len(out["mean"]))
print("First 5 forecast values:", out["mean"][:5])

Next steps

  • Learn how to include prediction intervals using the level argument in model.predict.
  • Explore advanced models like chronax.models.NBEATS for deep learning forecasts.
  • Use model.forecast for a combined fit and predict operation.
  • Understand the structure of the returned params dictionary.