Controlling the Level of Fine-Tuning
Learn how to use the finetune_depth parameter to control the extent of fine-tuning in TimeGPT models.
Use the finetune_depth parameter to control how many model parameters TimeGPT adjusts during fine-tuning. Valid values include [1, 2, 3, 4, 5]
. Generally, higher values can yield better performance yet also increase training time and the risk of overfitting.
Key Concept: finetune_depth
The finetune_depth parameter determines how extensively TimeGPT is adapted to your dataset. A depth of 1 tunes only a small subset of parameters, while 5 fine-tunes the entire model.
Be cautious when choosing a large finetune_depth
on small datasetsβit can lead to overfitting, hurting prediction accuracy.
1. Import Packages
First, import the required packages and initialize the Nixtla client.
2. Load Data
Next, load the dataset and split it into training and testing sets to analyze the effect of different finetune_depth
values.
3. Fine-Tuning With finetune_depth
For Azure AI, specify model="azureai"
in the forecast
method. The public API supports timegpt-1
and timegpt-1-long-horizon
.
Now, fine-tune TimeGPT with varying depths to compare performance. Note that larger depths can yield better results with sufficiently large datasets but may lead to overfitting on smaller ones.
Evaluate the forecasts using MAE and MSE metrics:
unique_id | metric | TimeGPT_depth1 | TimeGPT_depth2 | TimeGPT_depth3 | TimeGPT_depth4 | TimeGPT_depth5 |
---|---|---|---|---|---|---|
0 | mae | 22.675540 | 17.908963 | 21.318518 | 24.745096 | 28.734302 |
0 | mse | 677.254283 | 461.320852 | 676.202126 | 991.835359 | 1119.722602 |
The results show that finetune_depth=2
yields the lowest MAE and MSE, making it optimal for this dataset. However, depths of 4 and 5 lead to overfitting, demonstrating the importance of balanced fine-tuning.
Choosing the right fine-tuning parameters often involves experimentation. Monitor performance carefully and adjust finetune_steps
and finetune_depth
based on your dataset size and complexity.