网址https://book.douban.com/reading/46607817/

建立回归器后,需要建立评价回归器拟合效果的指标模型。

平均误差(mean absolute error):这是给定数据集的所有数据点的绝对误差平均值

均方误差(mean squared error):给定数据集的所有数据点的误差的平方的平均值,最流行

中位数绝对误差(mean absolute error):给定数据集的所有数据点的误差的中位数,可以消除异常值的干扰

解释方差分(explained variance score):用于衡量我们的模型对数据集波动的解释能力,如果得分为1.0,表明我们的模型是完美的。

R方得分(R2 score):读作R方,指确定性相关系数,用于衡量模型对未知样本预测的效果,最好的得分为1.0,值也可以是负数。

对应代码:

import sklearn.metrics as sm

print('mean absolute error=',round(sm.mean_absolute_error(y_test,y_test_pre),2))
print('mean squared error=',round(sm.mean_squared_error(y_test,y_test_pre),2))
print('median absolute error=',round(sm.median_absolute _error(y_test,y_test_pre),2))
print('explained variance score=',round(sm.explained_variance _score(y_test,y_test_pre),2))
print('R2 score=',round(sm.r2_score(y_test,y_test_pre),2))

通常情况下,尽量保证均方误差最低,而且解释方差分最高。

相关文章:

  • 2022-01-07
  • 2021-08-19
  • 2021-05-01
  • 2021-10-01
  • 2022-12-23
  • 2021-06-29
  • 2021-05-18
  • 2021-07-12
猜你喜欢
  • 2021-08-08
  • 2022-12-23
  • 2021-09-19
  • 2021-05-16
  • 2021-09-14
  • 2021-09-05
  • 2021-06-26
相关资源
相似解决方案