예측값과 참값의 Mean Absolute percentage error (MAPE)를 계산하고 싶습니다. 나는 here에서 해결책을 찾았지만 이것은 내가 스파이더를 사용하고있는 라인 mask = a <> 0
파이썬에서의 MAPE 계산
def mape_vectorized_v2(a, b):
mask = a <> 0
return (np.fabs(a - b)/a)[mask].mean()
def mape_vectorized_v2(a, b):
File "<ipython-input-5-afa5c1162e83>", line 1
def mape_vectorized_v2(a, b):
^
SyntaxError: unexpected EOF while parsing
에 잘못된 구문 오류를 제공하고 보여줍니다. 내 예측 값은 타입 np.array이며 진정한 가치는
type(predicted)
Out[7]: numpy.ndarray
type(y_test)
Out[8]: pandas.core.frame.DataFrame
어떻게 내가이 오류를 지우고 MAPE 계산을 진행 할 dataframe입니까?
편집 : 파이썬에서
predicted.head()
Out[22]:
Total_kWh
0 7.163627
1 6.584960
2 6.638057
3 7.785487
4 6.994427
y_test.head()
Out[23]:
Total_kWh
79 7.2
148 6.7
143 6.7
189 7.2
17 6.4
np.abs(y_test[['Total_kWh']] - predicted[['Total_kWh']]).head()
Out[24]:
Total_kWh
0 NaN
1 NaN
2 NaN
3 NaN
4 0.094427
'마스크 = A는 = 0' – jezrael