機器學習1-關於回歸問題的准確性評價


網址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))

通常情況下,盡量保證均方誤差最低,而且解釋方差分最高。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM