add_history=True argument.
1. Import packages
First, we install and import the required packages and initialize the Nixtla client.👍 Use an Azure AI endpoint To use an Azure AI endpoint, set thebase_urlargument:nixtla_client = NixtlaClient(base_url="you azure ai endpoint", api_key="your api_key")
2. Load data
Now you can start to make forecasts! Let’s import an example:| timestamp | value | |
|---|---|---|
| 0 | 1949-01-01 | 112 |
| 1 | 1949-02-01 | 118 |
| 2 | 1949-03-01 | 132 |
| 3 | 1949-04-01 | 129 |
| 4 | 1949-05-01 | 121 |
3. Historical forecast
Let’s add fitted values. Whenadd_history is set to True, the output
DataFrame will include not only the future forecasts determined by the h
argument, but also the historical predictions. Currently, the historical
forecasts are not affected by h, and have a fix horizon depending on
the frequency of the data. The historical forecasts are produced in a
rolling window fashion, and concatenated. This means that the model is
applied sequentially at each time step using only the most recent
information available up to that point.
📘 Available models in Azure AI If you are using an Azure AI endpoint, please be sure to setmodel="azureai":nixtla_client.forecast(..., model="azureai")For the public API, we support two models:timegpt-1andtimegpt-1-long-horizon. By default,timegpt-1is used. Please see this tutorial on how and when to usetimegpt-1-long-horizon.
| timestamp | TimeGPT | |
|---|---|---|
| 0 | 1951-01-01 | 135.483673 |
| 1 | 1951-02-01 | 144.442398 |
| 2 | 1951-03-01 | 157.191910 |
| 3 | 1951-04-01 | 148.769363 |
| 4 | 1951-05-01 | 140.472946 |
Please note, however, that the initial values of the series are not
included in these historical forecasts. This is because TimeGPT
requires a certain number of initial observations to generate reliable
forecasts. Therefore, while interpreting the output, it’s important to
be aware that the first few observations serve as the basis for the
model’s predictions and are not themselves predicted values.
