MSE(均方误差)、RMSE (均方根误差)、MAE (平均绝对误差)
生活随笔
收集整理的這篇文章主要介紹了
MSE(均方误差)、RMSE (均方根误差)、MAE (平均绝对误差)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、MSE(均方誤差)(Mean Square Error)
MSE是真實(shí)值與預(yù)測值的差值的平方然后求和平均。
范圍[0,+∞),當(dāng)預(yù)測值與真實(shí)值完全相同時(shí)為0,誤差越大,該值越大。
import numpy as np from sklearn import metrics y_true = np.array([1.0, 5.0, 4.0, 3.0, 2.0, 5.0, -3.0]) y_pred = np.array([1.0, 4.5, 3.5, 5.0, 8.0, 4.5, 1.0]) print(metrics.mean_squared_error(y_true, y_pred)) # 8.107142857142858
2、
RMSE (均方根誤差)(Root Mean Square Error)
import numpy as np from sklearn import metrics y_true = np.array([1.0, 5.0, 4.0, 3.0, 2.0, 5.0, -3.0]) y_pred = np.array([1.0, 4.5, 3.5, 5.0, 8.0, 4.5, 1.0]) print(np.sqrt(metrics.mean_squared_error(y_true, y_pred)))
3、MAE (平均絕對誤差)(Mean Absolute Error)
import numpy as np from sklearn import metrics y_true = np.array([1.0, 5.0, 4.0, 3.0, 2.0, 5.0, -3.0]) y_pred = np.array([1.0, 4.5, 3.5, 5.0, 8.0, 4.5, 1.0]) print(metrics.mean_absolute_error(y_true, y_pred))
總結(jié)
以上是生活随笔為你收集整理的MSE(均方误差)、RMSE (均方根误差)、MAE (平均绝对误差)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Gitlab-CI持续集成之Runner
- 下一篇: 网线过长怎么办路由器网线过长如何解决