"default"
- a proprietary loss function that is robust to outliers"mae"
- mean absolute error"mse"
- mean squared error"rmse"
- root mean squared error"mape"
- mean absolute percentage error"smape"
- symmetric mean absolute percentage error
1. Import packages
First, we import the required packages and initialize the Nixtla client.👍 Use an Azure AI endpoint To use an Azure AI endpoint, remember to set also thebase_url
argument:nixtla_client = NixtlaClient(base_url="you azure ai endpoint", api_key="your api_key")
2. Load data
Let’s fine-tune the model on a dataset using the mean absolute error (MAE). For that, we simply pass the appropriate string representing the loss function to thefinetune_loss
parameter of the forecast
method.
unique_id | timestamp | value | |
---|---|---|---|
0 | 1 | 1949-01-01 | 112 |
1 | 1 | 1949-02-01 | 118 |
2 | 1 | 1949-03-01 | 132 |
3 | 1 | 1949-04-01 | 129 |
4 | 1 | 1949-05-01 | 121 |
3. Fine-tuning with Mean Absolute Error
Let’s fine-tune the model on a dataset using the Mean Absolute Error (MAE). For that, we simply pass the appropriate string representing the loss function to thefinetune_loss
parameter of the forecast
method.
📘 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-1
andtimegpt-1-long-horizon
. By default,timegpt-1
is used. Please see this tutorial on how and when to usetimegpt-1-long-horizon
.

- Robust to outliers
- Easy to understand
- You care equally about all error sizes
- Same units as your data
- You want to penalize large errors more than small ones
- Sensitive to outliers
- Used when large errors must be avoided
- Not the same units as your data
- Brings the MSE back to original units of data
- Penalizes large errors more than small ones
- Easy to understand for non-technical stakeholders
- Expressed as a percentage
- Heavier penalty on positive errors over negative errors
- To be avoided if your data has values close to 0 or equal to 0
- Fixes bias of MAPE
- Equally senstitive to over and under forecasting
- To be avoided if your data has values close to 0 or equal to 0
📘 Available models in Azure AI If you are using an Azure AI endpoint, please be sure to setGreat! We have predictions from TimeGPT using all the different loss functions. We can evaluate the performance using their associated metric and measure the improvement.model="azureai"
:nixtla_client.forecast(..., model="azureai")
For the public API, we support two models:timegpt-1
andtimegpt-1-long-horizon
. By default,timegpt-1
is used. Please see this tutorial on how and when to usetimegpt-1-long-horizon
.
mae | mse | rmse | mape | smape | |
---|---|---|---|---|---|
Metric improvement (%) | 8.54 | 0.31 | 0.64 | 31.02 | 7.36 |