SKLearn中预测准确率函数介绍
1、在使用Sklearn进行机器学习算法预测测试数据时,常用到classification_report函数来进行测试的准确率的计算输
#开始预测
y_pred = clf.predict(X_test)
print("done in %0.3fs" % (time() - t0))
#通过该函数,比较预测出的标签和真实标签,并输出准确率
print(classification_report(y_test, y_pred))
#建立一个矩阵,以真实标签和预测标签为元素
print(confusion_matrix(y_test, y_pred, labels=range(n_classes)))
下图为Eclipse下classification_report函数的源代码: