Custom loss function in AutoMLForecast.fit Hyperparameter tuning #430
-
I'm new to implementing time series forecasting using the MLForecast library and ran into a problem specifying the loss function for hyperparameter tuning. I'm using the AutoMLForecast.fit method to find the best parameters for multiple models. One of the parameters I want to tweak is the loss function. In the documentation I see that this parameter requires some kind of function that takes the validation and the trainings data as input. I can't figure out how to set this up properly to use for example MAE. I've tried using the UtilsForecast (from utilsforecast.losses import mae), but that doesn't seem to work. Anyone who has an idea which utils I can use or how to write them myself? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey. You can use MAE with the following: from utilsforecast.losses import mae
def loss_fn(df, train_df):
return mae(df, models=["model"])["model"].mean() |
Beta Was this translation helpful? Give feedback.
Hey. You can use MAE with the following: