且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何找出准确度?

更新时间:2023-02-26 18:39:24

scikit 中的大多数分类器都有一个内置的 score() 函数,您可以在其中输入 X_test 和 y_test,它将输出适当的度量那个估计.对于分类估计器,它主要是'平均准确度'.

Most classifiers in scikit have an inbuilt score() function, in which you can input your X_test and y_test and it will output the appropriate metric for that estimator. For classification estimators it is mostly 'mean accuracy'.

还有 sklearn.metrics 有许多可用的函数可以输出不同的指标,例如 accuracyprecisionrecall 等.

对于您的具体问题,您需要accuracy_score

For your specific question you need accuracy_score

from sklearn.metrics import accuracy_score
score = accuracy_score(iris.target, pr)