MSE(均方误差)、RMSE (均方根误差)、MAE (平均绝对误差)

1、MSE(均方误差)(Mean Square Error)

MSE是真实值与预测值的差值的平方然后求和平均。
在这里插入图片描述

范围[0,+∞),当预测值与真实值完全相同时为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))

4、转载自

MSE(均方误差)、RMSE (均方根误差)、MAE (平均绝对误差)

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐