【问题标题】:What is the real result of an sklearn analysis?sklearn 分析的真正结果是什么?
【发布时间】:2018-12-18 21:51:57
【问题描述】:

我试图获得 sklearn 分析的结果,而不是准确性。我的意思是,我想看看我的模型会产生什么结果。

clf = RandomForestClassifier()

# train the classifier using the training data
clf.fit(features_train, labels_train)

acc_test = clf.score(features_test, labels_test)
acc_train = clf.score(features_train, labels_train)

print ("Train Accuracy:", acc_train)

我所拥有的只是准确性,到目前为止我已经尝试过(我在堆栈上找到了这个解决方案,也许我错过了一些东西),但它不起作用:

labels = clf.fit(features_train, labels_train)
print (labels.dtype)

我有两个可能的输出(0 或 1),然后我想自己查看正确的结果,一个 csv 文件。我怎么能这样做?

【问题讨论】:

  • 您正在寻找.predict ...您阅读过文档吗?

标签: python python-3.x machine-learning scikit-learn


【解决方案1】:

clf.fit 返回自我。所以你得到的不是标签,而是分类器的一个实例。

这应该可以预测测试数据的值。如果您愿意,可以将其保存到 csv 文件中。

preds_test = clf.predict(features_test)
print(preds_test)

【讨论】:

  • 谢谢!!我的测试大小设置为 0.20。如果我想获取整个数据,我应该选择测试大小为 1?即使它看起来不可靠?还是保存模型,然后应用到整个数据更好?谢谢!!
  • 你对分类器的预测应该在分类器没有看到的测试集上进行评估。如果您想查看整个数据集,可以在拆分之前对其进行馈送。
猜你喜欢
  • 2021-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-23
  • 1970-01-01
  • 2018-06-22
  • 2023-02-01
  • 2016-05-09
相关资源
最近更新 更多