Basic question about `add_history=True`. I have a ...
# timegpt
a
Basic question about
add_history=True
. I have a dataframe,
df_red
, with daily data rows, and I'm calling the forecast function as shown below with a forecast horizon,
h=5
and
add_history=True
.
df_fcst = nixtla_client.forecast(df_red, h=5, freq = 'B', time_col='target_date', target_col='today_close', add_history=True)
This returns the
df_fcst
dataframe (screenshot below), which has a
TimeGPT
forecast column. For each date/row in the
TimeGPT
forecast column, does the value represent the forecast for
h
periods (days in my case) from the date in the same row? E.g. Does the
TimeGPT
value for 2023-08-23 represent the forecasted value for 2023-08-30 (in
h=5
business days from 2023-08-23). I had assumed that it does (logical) but then came across something in the docs that seems to negate my assumption.
For reference, here is the content in the docs that is causing my confusion: _"Currently, the historical forecasts are not affected by the
h
parameter. They have a fixed horizon depending on the frequency of the data. 4. When you use
add_history=True
, the output DataFrame will include both the historical predictions and the future forecasts."_
m
Hello! The values in the column
TimeGPT
are aligned with the date. This means that the value for 2023-08-23 is the value returned by TimeGPT for the date 2023-08-23. The
add_history
parameter simply returns the fitted values of TimeGPT. It's basically the insample values. If set to
False
, then only the predictions are returned. Let me know if that answers your question!
a
Thanks Marco. So, is the value shown on 2023-08-23 the forecasted value for that date, where that forecasted value was created h days prior, on 2023-08-18. Sorry, that's just a rephrasing/date-shift of my original question. Alternatively, was the forecasted value shown in the 2023-08-23 row created 1-day prior? Basically, there has to be some h-period value associated with each forecasted value, and I'm trying to figure out what it is.
m
TimeGPT takes an input sequence and generates an output sequence. So the predictions simply come from the default input size. The predictions are not made one at a time.
a
So, if I need a historical record of 5-day forecasts from each date row in my dataframe, would I have to iterate through all dates/rows one and call the forecast method for each row and then capture the fifth row in the forecast dataframe?
m
This can be done with cross-validation. You can follow this guide for a detailed tutorial on cross-validation with TimeGPT.
a
Okay, great. I started playing around with it. I'll look into it more. Thanks for forwarding the tutorial.
❤️ 1