I use manual MAE calculations and sklearn.metrics and got different results. Why?
from sklearn.metrics import mean_absolute_error as MAE
cnt = 0
error = 0
len_y = len(y)
len_y_pred = len(y_pred)
if len_y == len_y_pred:
for i in range(len_y):
if y_pred[i] != y.values[i]:
cnt += 1
error += abs(y.values[i] - y_pred[i])
print('manual MAE = ', error / cnt)
# MAE from sklearn
print('sklearn MAE = ', MAE(y, y_pred))
output:
manual MAE = 96189.48047877151
sklearn MAE = 15074.239113119293
why so different?
thanks