MSE 均方误差(Mean Square Error)
RMSE 均方根误差(Root Mean Square Error)
其实就是MSE加了个根号,这样数量级上比较直观,比如RMSE=10,可以认为回归效果相比真实值平均相差10
MAE 平均绝对误差(Mean Absolute Error)
MAPE 平均绝对百分比误差(Mean Absolute Percentage Error)
SMAPE 对称平均绝对百分比误差(Symmetric Mean Absolute Percentage Error)
scikit-learn中实现:
# MSE, MAE, R2, RMSE法一
from sklearn.metrics import mean_squared_error #MSE
from sklearn.metrics import mean_absolute_error #MAE
from sklearn.metrics import r2_score#R 2
#调用
mean_squared_error(y_test,y_predict)
mean_absolute_error(y_test,y_predict)
np.sqrt(mean_squared_error(y_test,y_predict)) # RMSE
r2_score(y_test,y_predict)
# MSE, MAE, R2, RMSE法二
from sklearn import metrics
metrics.mean_squared_error(y_test,y_predict)
metrics.mean_absolute_error(y_test,y_predict)
np.sqrt(metrics.mean_squared_error(y_test,y_predict)) # RMSE
metrics.r2_score(y_test,y_predict)
# MAPE和SMAPE
def mape(y_true, y_pred):
return np.mean(np.abs((y_pred - y_true) / y_true)) * 100
def smape(y_true, y_pred):
return 2.0 * np.mean(np.abs(y_pred - y_true) / (np.abs(y_pred) + np.abs(y_true))) * 100
# 调用
mape(y_true, y_pred)
smape(y_true, y_pred)
参考文献:
https://blog.csdn.net/skullFang/article/details/79107127
https://blog.csdn.net/guolindonggld/article/details/87856780
来源:CSDN
作者:凯旋的铁铁
链接:https://blog.csdn.net/qq_41870157/article/details/104699118