Reputation: 26206
There is a check_array
function for calculating mean absolute percentage error (MAPE)
in the recent version of sklearn
but it doesn't seem to work the same way as the previous version.
import numpy as np
from sklearn.utils import check_array
def calculate_mape(y_true, y_pred):
y_true, y_pred = check_array(y_true, y_pred)
return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
y_true = [3, -0.5, 2, 7]; y_pred = [2.5, -0.3, 2, 8]
calculate_mape(y_true, y_pred)
This is returning an error: ValueError: not enough values to unpack (expected 2, got 1)
. Is there any fix for this error?
Upvotes: 4
Views: 2164