I built a tensorflow neural-network with three output classes.
My loss function is currently val_mean_absolute_percentage_error
as not the absolute distance but the relative distance between target and predicted variable matters.
However, the mean absolute percentage error calculated as
1/n sum(|(y_test - y_pred) / y_test|)
is not fully appropriate for my problem as it penalizes stronger if y_pred > y_test
Example 1: y_test = 5, y_pred = 2 --> Mape = 0.6
Example 2: y_pred = 5, y_test = 2 --> Mape = 1.5
However, the above examples should penalize equally.
Does anyone know which (custom) loss function may more suitable for my problem?
For bigger differences between the
y_true
andy_pred
you could consider to use themse loss
instead ofmae loss
; in case of the RMSE/MSE, as the errors are squared prior to being averaged, the RMSE gives a higher weight for larger errors.The problem is that you divide to
y_test
, hence the difference in results. You could first try to remove the denominator to obtain the same MAPE and if you still get bigger values in magnitude betweeny_test
andy_pred
, consider usingRMSE
.