I have a time series data that is not stationary (with trend and seasonal components) so in order to make it stationary, I've applied a difference transform of 1. Due to this effect, some negative values appeared. I am applying cross validation and I want to calculate error metrics such as MAPE/sMAPE on my validation sets, but due to the existence of negative values, MAPE & sMAPE are getting greater than 100%. I know that MAPE has many pitfalls but I need a percentage error metric.
A similar issue is asked here in this thread, but I am still not sure about this.
- Question 1: How can I avoid values greater than 100% when negative values exist in my data ?
- Question 2: Are there alternatives to MAPE/sMAPE that combat this issue ? perhaps suited also for time series problems
I am using the following code snippets:
def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = np.array(y_true), np.array(y_pred)
return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
def symmetric_mean_absolute_percentage_error(y_true, y_pred):
return 100 / len(y_true) * np.sum(2 * np.abs(y_pred - y_true) / (np.abs(y_true) + np.abs(y_pred)))