ARIMA Baseline Forecasts

Use ARIMA for baseline forecasts in this Applied AI engineering tutorial — hands-on steps, troubleshooting, and what to study next.

Focus: use arima for baseline forecasts

Sponsored

Every serious time-series project starts with the same uncomfortable question: "What would happen if we just did nothing smart?" Most teams jump straight to deep learning or gradient boosting, only to discover their fancy model barely beats a naive forecast — and they have no way to prove it.

This lesson teaches you how to use ARIMA for baseline forecasts — the statistical workhorse that gives you a defensible, reproducible benchmark within minutes. You'll stop guessing whether your model adds value and start measuring it. By the end, you'll have a working ARIMA baseline you can run in Python and a clear path to compare it against anything more complex.

The problem this lesson solves

Forecasting without a baseline is like running a race with no finish line. You build an LSTM, tune hyperparameters for a day, and get an MAE of 12.3. Great? Terrible? Without a benchmark, you literally cannot tell.

Here's the pain:

  • You can't validate model improvement — every new model claims 'we beat the old one,' but you have no reference point.
  • Stakeholders ask impossible questions — 'Is 5% error good?' You have no answer.
  • You waste weeks on complex models — when a simple autoregressive model might capture 80% of the signal.

This lesson cuts through that noise. You'll learn to fit an ARIMA model as a baseline forecast, generating predictions you can compare any future model against. It's not about winning a Kaggle competition — it's about establishing a minimum viable forecast that tells you whether complexity actually pays off.

Core concept / mental model

Think of a time series as a mountain road. The road has a general direction (trend), it has turns (seasonality), and it has bumps (noise). An ARIMA model is like a driver who looks in the rearview mirror to predict the next few meters of road — it assumes the recent past repeats itself, at least for a short stretch.

ARIMA stands for Autoregressive Integrated Moving Average. That's a mouthful, so break it down:

  • AR (Autoregressive): The future depends on past values. A value at time t is a weighted sum of previous values, plus some noise.
  • I (Integrated): The series is differenced to make it stationary — meaning the statistical properties (mean, variance) don't change over time.
  • MA (Moving Average): The future depends on past forecast errors.

A full ARIMA model is written as ARIMA(p, d, q), where:

  • p: number of lag observations included (autoregressive terms)
  • d: number of times the data is differenced (to remove trend)
  • q: number of lag forecast errors included (moving average terms)

In practice, your job is rarely to design the perfect ARIMA model. For a baseline, you can rely on automatic selection — let the library pick good p, d, and q for you. The key is understanding what the model is doing so you can trust it as a benchmark.

How it works step by step

Building an ARIMA baseline follows a logical, repeatable pipeline. Here's the cause-and-effect chain:

1. Load and inspect your time series

You start with a univariate time series (one value per time step). Visualize it to see trend, seasonality, and outliers.

2. Make the series stationary (if needed)

ARIMA requires stationarity — a constant mean and variance over time. You check this with statistical tests (like the Augmented Dickey-Fuller test) and apply differencing until the series becomes stationary. The d parameter reflects the number of differences.

3. Select model order

You choose p, d, q. You can do this manually using ACF (autocorrelation function) and PACF (partial autocorrelation function) plots, but for a baseline, use automatic selection like auto_arima from the pmdarima package. It optimizes the Akaike Information Criterion (AIC) — a trade-off between goodness-of-fit and model complexity.

4. Fit the model

With the order chosen, fit the ARIMA model on the historical data. This estimates the coefficients for the AR and MA terms.

5. Forecast and evaluate

Generate predictions for the future horizon and compare them to actual values (or a hold-out set). Common metrics: MAE (Mean Absolute Error) or RMSE (Root Mean Squared Error). This becomes your baseline metric.

6. Document and compare

Record your baseline metric. When you build a more complex model later, you compare it against this number. If the advanced model doesn't beat it significantly, it's not worth the complexity.

Hands-on walkthrough

Let's put this into practice with a real Python example. We'll use the pmdarima library, which provides automatic ARIMA selection — perfect for a baseline.

First, install the required packages:

pip install pandas numpy pmdarima matplotlib

Example 1: Fitting a baseline ARIMA on synthetic data

import numpy as np
import pandas as pd
from pmdarima import auto_arima
from sklearn.metrics import mean_absolute_error

# Generate a simple time series: upward trend with noise
np.random.seed(42)
t = np.arange(100)
series = 2 * t + 10 + np.random.normal(0, 10, size=len(t))

# Split into train and test (last 20 points are test)
train = series[:-20]
test = series[-20:]

# Fit ARIMA with auto-selection
model = auto_arima(
    train,
    seasonal=False,
    stepwise=True,
    trace=True
)

# Forecast the next 20 steps
forecast, conf_int = model.predict(n_periods=len(test), return_conf_int=True)

# Evaluate
mae = mean_absolute_error(test, forecast)
print(f"Baseline MAE: {mae:.2f}")
print(f"Forecast: {forecast}")

Expected output (approx):

Performing stepwise search to minimize aic
 ARIMA(2,0,2) with drift         : AIC=860.72
 ARIMA(0,0,0) with drift         : AIC=1230.48
 ARIMA(1,0,1) with drift         : AIC=858.27
 ARIMA(2,0,1) with drift         : AIC=859.25
 ARIMA(1,0,0) with drift         : AIC=1013.54
 ARIMA(1,0,2) with drift         : AIC=859.86
 ARIMA(0,0,1) with drift         : AIC=1151.20
 ARIMA(2,0,3) with drift         : AIC=860.50
 ARIMA(0,0,2) with drift         : AIC=1129.75
 ARIMA(3,0,2) with drift         : AIC=861.61
 ARIMA(3,0,3) with drift         : AIC=860.91

Best model:  ARIMA(1,0,1) with drift
Baseline MAE: 14.23
Forecast: [201.2, 202.1, ...]

Example 2: Handling seasonality

For data with monthly or quarterly patterns, enable seasonal ARIMA (SARIMA):

# Monthly data with annual seasonality
monthly_series = ...  # your data

model = auto_arima(
    monthly_series,
    seasonal=True,
    m=12,  # monthly seasonality
    stepwise=True,
    trace=True
)

forecast = model.predict(n_periods=12)

Output: The model will automatically detect the seasonal orders and forecast the next year.

Example 3: Saving and loading your baseline model

A baseline is only useful if you can reuse it later:

import joblib

# Save the fitted model for future comparison
joblib.dump(model, "arima_baseline.pkl")

# Load it later
loaded_model = joblib.load("arima_baseline.pkl")

Compare options / when to choose what

ARIMA is not the only baseline. Here's how it stacks up against common alternatives:

Method Pros Cons Best for
ARIMA/SARIMA Handles trend and seasonality, interpretable, auto-parameter selection Requires stationarity, univariate only, struggles with exogenous variables Univariate series with clear trend/seasonality
Naive persistence Zero effort, ideal for random walk Ignores all patterns, terrible for trending series As a sanity check, not a real baseline
Moving average Simple, smooths noise Lags behind trends, no forecast intervals Short-term stable series
Exponential smoothing Lightweight, handles seasonality Linear trend assumptions, less flexible than ARIMA Simple seasonal data

When to choose what:

Use ARIMA as your primary baseline for any univariate time series. It's powerful enough to capture real patterns yet simple enough to be reproducible. Only fall back to naive or moving-average if you have less than 30 data points — ARIMA needs enough history to learn from.

Variations:

  • SARIMAX (pmdarima) — adds exogenous variables (e.g., promotions, holidays) to ARIMA.
  • Prophet (Meta) — robust to missing data and holidays, but less statistical rigor.
  • NeuralProphet — hybrid of Prophet and deep learning, more complex, not baseline material.

Troubleshooting & edge cases

1. "ValueError: Data has no frequency"

You provided a plain list or a Series without a datetime index. Fix by converting to a datetime-indexed Series:

series = pd.Series(data, index=pd.date_range(start='2020-01-01', periods=len(data), freq='D'))

2. "The model predicts a flat line"

Your series might be non-stationary in a weird way, or the auto-selected model is too simple. Try increasing max_p and max_q in auto_arima, or force differencing:

model = auto_arima(train, seasonal=False, d=1, max_p=5, max_q=5)

3. "The forecasts are nonsense (huge spikes)"

Your data has extreme outliers. ARIMA is sensitive to them. Consider winsorizing or log-transforming the data before fitting, then transform back:

from scipy.stats import boxcox
transformed, lambda_ = boxcox(series)
# Fit ARIMA on transformed, then inverse-transform forecasts

4. "auto_arima is too slow"

For large datasets, reduce the search space:

model = auto_arima(train, seasonal=False, stepwise=True, max_p=2, max_q=2, d=1, n_jobs=1)

5. "I get a convergence warning"

This often happens with small samples or non-optimal orders. Override the optimizer or increase iterations:

model = auto_arima(train, stepwise=True, max_iter=100, method="lbfgs")

Common Mistakes

  • Skipping stationarity checks — ARIMA assumes stationarity, so always check with ADF test before trusting results.
  • Overfitting the baseline — you don't need the 'best' ARIMA; you need a reasonable one. Aggressive tuning defeats the purpose.
  • Using a hold-out set for baseline evaluation only — you must save part of your data to evaluate both the baseline and future models on the same horizon.
  • Ignoring seasonality — if your data has weekly or yearly patterns, use seasonal=True and m to capture them; otherwise your baseline will be misleading.

Variations

  • SARIMAX — extends ARIMA to include exogenous variables, useful when you have calendar effects.
  • Prophet — easier to handle missing data and outliers, but less statistical interpretability.
  • NeuralProphet — hybrid of Prophet and deep learning, for more complex patterns, but not a baseline.

Real-World Use Cases

  • Retail demand prediction — baseline forecast for weekly sales to set safety stock levels before more advanced models.
  • Server load prediction — baseline forecast of web traffic to guide capacity planning and cost optimization.
  • Financial time series — baseline forecast of stock prices or volatility to benchmark algorithmic trading strategies.

Real-World Use Cases

  • Retail demand prediction — baseline forecast for weekly sales to set safety stock levels before more advanced models.
  • Server load prediction — baseline forecast of web traffic to guide capacity planning and cost optimization.
  • Financial time series — baseline forecast of stock prices or volatility to benchmark algorithmic trading strategies.

What you learned & what's next

You've taken a major step in your Applied AI engineering journey. You can now use ARIMA for baseline forecasts — fitting a reproducible, statistical model that gives you a benchmark metric in minutes. You understand the core concept (AR, I, MA) and why stationarity matters. You completed a hands-on exercise with auto_arima and evaluated the forecast with MAE.

You also learned how to compare ARIMA against other baselines and how to troubleshoot common issues. This skill is the foundation for every forecasting project you'll tackle.

What's next? In the next lesson, you'll learn how to evaluate your baseline against more advanced models — how to set up a proper validation harness so you never again wonder if your LSTM is actually better than a simple ARIMA. Stay tuned.

Practice Recap

Run the example on a real dataset of your choice (e.g., daily temperature or monthly sales). Change the forecast horizon to 7 and 30 steps, and note how MAE changes. Then, make a simple scatter plot of actual vs. forecast values. This will cement the workflow — load, fit, forecast, evaluate — so you can reuse it in every future project.

Practice recap

Run the example on a real dataset of your choice (e.g., daily temperature or monthly sales). Change the forecast horizon to 7 and 30 steps, and note how MAE changes. Then make a simple scatter plot of actual vs. forecast values to visualize performance.

Common mistakes

  • Skipping stationarity checks — always run the Augmented Dickey-Fuller test before trusting ARIMA results.
  • Overfitting the baseline — you don't need the 'best' ARIMA; you need a reasonable one. Avoid aggressive hyperparameter tuning.
  • Using a hold-out set only for baseline evaluation — reserve data to compare both baseline and future models on the same horizon.
  • Ignoring seasonality — enable seasonal=True and set m when data has weekly or yearly patterns.

Variations

  1. SARIMAX — extends ARIMA to include exogenous variables like holidays or promotions.
  2. Prophet — handles missing data and outliers gracefully, but is less statistically interpretable.
  3. NeuralProphet — a hybrid of Prophet and deep learning for more complex patterns, but heavier than a baseline.

Real-world use cases

  • Retail demand prediction — base forecast for weekly sales to set safety stock levels before advanced models.
  • Server load prediction — baseline forecast of web traffic to guide capacity planning and cost optimization.
  • Financial time series — baseline forecast of stock prices or volatility to benchmark algorithmic trading strategies.

Key takeaways

  • ARIMA is a statistical model for univariate time series — autoregressive, integrated, moving average.
  • A baseline forecast is the minimum viable prediction you compare all complex models against.
  • Auto-ARIMA (pmdarima) automatically selects p, d, q, saving you time and effort.
  • Always evaluate your baseline on a hold-out set to get a fair metric.
  • Common pitfalls include non-stationarity, ignored seasonality, and overfitting the baseline.
  • ARIMA is ideal for trend and seasonality; use simpler methods when data is too short.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.