chapter three

3 Forecasting with TimeGPT

 

This chapter covers

  • Defining generative models
  • Exploring the architecture and inner workings of TimeGPT
  • Forecasting with TimeGPT
  • Detecting anomalies with TimeGPT

In chapter 2, we built our own tiny foundation forecasting model and survived the challenges of building such models. Because we trained only on monthly data, for example, the model struggled to make accurate predictions on daily data. Thus, unless we’re willing to spend months collecting varied data and pretraining large models, we should use existing large time models.

In this chapter and the next six chapters, we’ll use a dataset that tracks the weekly sales of many Walmart stores from February 5, 2010 to October 26, 2012 as the forecasting scenario for the foundation models we explore in this book. This dataset is released under the Creative Commons 0 license. Although the original dataset tracked thousands of stores, we’ll use a subset of only four stores. The dataset also includes exogenous variables such as a holiday indicator, average temperature, average fuel price, average consumer price index (CPI), and average unemployment rate for each store location. We’ll use this dataset to compare the performance of different approaches throughout the book. The dataset was specifically selected for the presence of different types of external variables, allowing us to highlight different capabilities for each method because some models cannot handle exogenous features.

3.1 Defining generative pretrained transformers

3.2 Exploring TimeGPT

3.2.1 Training TimeGPT

3.2.2 Quantifying uncertainty in TimeGPT

3.3 Forecasting with TimeGPT

3.3.1 Initial setup

3.3.2 Zero-shot forecasting

3.3.3 Performance evaluation

3.4 Fine-tuning with TimeGPT

3.4.1 Fine-tuning TimeGPT

3.4.2 Evaluating the fine-tuned model

3.4.3 Controlling the depth of fine-tuning

3.5 Forecasting with exogenous variables

3.5.1 Preparing the exogenous features

3.5.2 Forecasting with exogenous variables

3.5.3 Explaining the effect of exogenous features with Shapley values

3.5.4 Evaluating forecasts with exogenous features

3.6 Cross-validating with TimeGPT