Learn how to handle missing values in time series data for accurate forecasting with TimeGPT.
ds
and y
.
ds | y | |
---|---|---|
0 | 2014-06-23 | 99 |
1 | 2014-06-24 | 72 |
2 | 2014-06-25 | 119 |
3 | 2014-06-26 | 135 |
4 | 2014-06-27 | 149 |
unique_id
) to handle multiple series if needed:
NixtlaClient
object with your Nixtla API key:
max_insample_length
argument of the plot
method or you
can simply zoom in on the plot.
fill_gaps
from utilsforecast
to insert the missing dates:
Before using TimeGPT, we need to ensure that:
fill_gaps
function from utilsforecast
,
a Python package from Nixtla that provides essential utilities for time series
forecasting, such as functions for data preprocessing, plotting, and evaluation.
The fill_gaps
function will fill in the missing dates in the data. To do this,
it requires the following arguments:
df
: The DataFrame containing the time series data.freq
(str or int): The frequency of the data.NOTE: In this tutorial, the data contains only one time series. However, TimeGPT supports passing multiple series to the model. In this case, none of the time series can have missing values from their individual earliest timestamp until their individual latest timestamp. If these individual time series have missing values, the user must decide how to fill these gaps for the individual time series. TheNow we need to decide how to fill the missing values in the target column. In this tutorial, we will use interpolation, but it is important to consider the specific context of your data when selecting a filling strategy. For example, if you are dealing with daily retail data, a missing value most likely indicates that there were no sales on that day, and you can fill it with zero. Conversely, if you are working with hourly temperature data, a missing value probably means that the sensor was not functioning, and you might prefer to use interpolation to fill the missing values. In this case, we will handle the newly inserted missing values by interpolation.fill_gaps
function provides a couple of additional arguments to assist with this (refer to the documentation for complete details), namelystart
andend
.
timegpt-1-long-horizon
model.
Forecast comparison between the test dataset and TimeGPT predictions
utilsforecast
. We will use Mean Absolute Error (MAE)
as the evaluation metric, but you can choose others like MSE, RMSE, etc.:
unique_id | metric | TimeGPT | |
---|---|---|---|
0 | id1 | mae | 1824.693059 |