【问题标题】:How do i check the accuracy of the result of a text classifier (scikit-learn)我如何检查文本分类器(scikit-learn)结果的准确性
【发布时间】:2017-08-20 07:02:59
【问题描述】:

我正在对用于文本分类的各种工具包进行一些探索性工作。我有一个关于确定文本分类器结果的准确性的问题。

以 20 个新闻组演示为例: http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html

假设我已经训练了我的数据并准备好我的测试数据来检查经过训练的分类器。如果我将单个文本短语传递给我的分类器并返回正确的结果(例如 'God ​​is love' => soc.religion.christian )我如何判断该结果的准确性是多少?

我还在后续部分中注意到,通过使用以下命令,我可以检查平均预测准确度。同样,我如何确定单次一次性测试的准确性?

np.mean(predicted == twenty_test.target)            
0.912...

顺便说一句,我注意到在 python 中使用 Watson Conversation Classifier API 调用时(下面的链接),API 返回一个置信度分数。我可以在 scikit-learn 中实现类似的东西吗?

https://www.ibm.com/watson/developercloud/conversation/api/v1/?python#send_message

"intent": "turn_on",
  "confidence": 0.99
}
  ],
 "output": {
"log_messages": [],
"text": [
  "Ok. Turning on the light."

谢谢 乔纳森

【问题讨论】:

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


    【解决方案1】:

    您需要使用predict_proba。这将为您提供介于 0 和 1 之间的置信度分数。

    model.fit(X, y)
    preds = model.predict_proba(single_test_sample)
    

    【讨论】:

    • 感谢 Abhishek,我将添加该代码并检查该结果的准确性。
    猜你喜欢
    • 2015-07-31
    • 2019-11-18
    • 2014-05-17
    • 2016-05-25
    • 2020-02-11
    • 2018-07-03
    • 2019-06-07
    • 2017-02-07
    • 2012-12-06
    相关资源
    最近更新 更多