Before running this notebook, please visit our dashboard to obtain your TimeGPT api_key.

Why TimeGPT?

TimeGPT is a powerful, general-purpose time series forecasting solution. Throughout this notebook, we compare TimeGPT’s performance against three popular forecasting approaches:

  • Classical model (ARIMA)
  • Machine learning model (LightGBM)
  • Deep learning model (N-HiTS)

Below are three core benefits that our users value the most:

Accuracy

TimeGPT consistently outperforms traditional models by accurately capturing complex patterns.

Speed

Quickly generates forecasts with minimal training and tuning requirements per series.

Ease of Use

Minimal setup and no complex preprocessing make TimeGPT immediately accessible for use.

Table of Contents

  1. Data Introduction
  2. Model Fitting
    1. TimeGPT
    2. ARIMA
    3. LightGBM
    4. N-HiTS
  3. Performance Comparison and Results
  4. Conclusion
1

1. Data Introduction

This notebook uses an aggregated subset from the M5 Forecasting Accuracy competition. The dataset:

  • Consists of 7 daily time series
  • Has 1,941 observations per series
  • Reserves the last 28 observations for evaluation on unseen data
Data Loading and Stats Preview
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from nixtla import NixtlaClient
from utilsforecast.plotting import plot_series
from utilsforecast.losses import mae, rmse, smape
from utilsforecast.evaluation import evaluate

nixtla_client = NixtlaClient(
    # api_key='my_api_key_provided_by_nixtla'
)

df = pd.read_csv(
    'https://datasets-nixtla.s3.amazonaws.com/demand_example.csv',
    parse_dates=['ds']
)

# Display aggregated statistics per time series
df.groupby('unique_id').agg({
    "ds": ["min", "max", "count"],
    "y": ["min", "mean", "median", "max"]
})

Below is a preview of the aggregated statistics for each of the 7 time series.

Next, we split our dataset into training and test sets. Here, we use data up to “2016-04-24” for training and the remaining data for testing.

Train-Test Split Example
df_train = df.query('ds <= "2016-04-24"')
df_test = df.query('ds > "2016-04-24"')

print(df_train.shape, df_test.shape)
# (13391, 3) (196, 3)
2

2. Model Fitting (TimeGPT, ARIMA, LightGBM, N-HiTS)

TimeGPT is compared against four different modeling approaches. Each approach forecasts the final 28 days of our dataset and we compare results across Root Mean Squared Error (RMSE) and Symmetric Mean Absolute Percentage Error (SMAPE).

3

3. Performance Comparison and Results

Below is a summary of the performance metrics (RMSE and SMAPE) on the test dataset. TimeGPT consistently delivers superior forecasting accuracy:

Comparative Performance Visualization

Benchmark Results

4

4. Conclusion

TimeGPT stands out with its accuracy, speed, and ease of use. Get started today by visiting the
Nixtla dashboard to generate your
api_key and access advanced forecasting with minimal overhead.