python - sklearn 中的预测评分(Python 机器学习)

标签 python machine-learning scikit-learn

我正在浏览以下 IPython Notebook,它分析了 Iris dataset

作者在笔记本中的某个时刻构建了以下模型:

enter image description here

此时我感到很困惑。最后一行发生了什么? 根据我的了解,您应该根据模型创建一个预测,然后将该预测与 y_test 值进行比较。

我会做以下事情:

predictions = decision_tree_classifier.predict(X_test)
from sklearn.metrics import classification_report
print classification_report(y_test, predictions)

当作者根据 testing_inputstesting_classes 生成分数时,会发生什么情况?

最佳答案

来自docs :

score(X, y, sample_weight=None)

Returns the mean accuracy on the given test data and labels.

这正是它的作用。它在内部对 X_test 进行预测,生成 y_pred 并将其与 y_test 进行比较以计算准确性分数。

您所做的事情类似,但分两步。您首先进行预测,然后与 y_test 进行比较。此外,您还打印出精度、召回率和 f1 分数。

关于python - sklearn 中的预测评分(Python 机器学习),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44915004/

相关文章:

具有大数据的 Python 集合计数器

python - 需要帮助开始使用 google app engine(PYTHON 2.7)

machine-learning - 如何解释稀疏的输出?

c++ - 我可以增加 OpenCV 中 SVM 训练标签的数量吗?

machine-learning - 机器学习如何与大数据结合?

machine-learning - H2O ML Python 备忘单或 H2O 的 Python API 与 scikit-learn 之间的比较

python - 制作正则表达式Python

python - 如何在 Python 中创建进程间数据结构?

python - 随机森林过拟合

python - 导入错误 : No module name sklearn. external.six