我相信我在純python中計算RMSE時發生錯誤。以下是代碼。Python純RMSE vs Sklearn
y_true = [3, -0.5, 2, 7]
y_pred = [2.5, 0.0, 2, 8]
e = abs(np.matrix(y_pred) - np.matrix(y_true)).A1
ee = np.dot(e,e)
np.sqrt(ee.sum()/3)
This returns: 0.707
然而,當我嘗試用Sklearn
mean_squared_error(np.matrix(y_true),np.matrix(y_pred))**0.5
This returns: 0.612
任何想法是怎麼回事?很確定我的Python代碼是正確的。
爲什麼sklearn除以4? – cloud36
@ cloud36:看看我的回答 – MMF