【问题标题】:Accessing the confidence parameters in IBM Watson nl-classifier访问 IBM Watson nl-classifier 中的置信度参数
【发布时间】:2017-09-27 10:53:37
【问题描述】:

我正在构建一个 Web 应用程序,当我输入网页时,它会获取网页的文本内容,对其进行标记并将每一行提供给经过训练的分类器,我想要对那些行置信度参数 > 0.98。以下是取自 bluemix 网站的示例:

     {
  "classifier_id": "10D41B-nlc-1",
  "url": "https://gateway.watsonplatform.net/natural-language-classifier    /api/v1/classifiers/10D41B-nlc-1/classify?text=How%20hot%20wil/10D41B-nlc-1",
  "text": "How hot will it be today?",
  "top_class": "temperature",
  "classes": [
    {
      "class_name": "temperature",
      "confidence": 0.9998201258549781
    },
    {
      "class_name": "conditions",
      "confidence": 0.00017987414502176904
    }
  ]
}

现在在上面的例子中,我想用 class_name: temperature where confidence > 0.95.

 #if class.temperature.confidence > 0.98
     #do something with it   

有可能吗?

【问题讨论】:

    标签: python nlp ibm-cloud classification ibm-watson


    【解决方案1】:

    从应用程序 NLP 返回 JSON 后,您可以在同一个 if 中加入两个条件 true 来执行此操作。

    在这种情况下:

    if classes.classes_name === 'temperature' and classes.confidence > 0.95 
    //do something
    

    Python 将andor 用于逻辑操作条件。 and 将检查这两个条件是否为true。如果是,就做点什么。

    【讨论】:

    • 它说dict没有属性'class_name'。在我调用分类器之后。
    • 我根据您在问题中返回的 json 向您展示了获取所需值的正确方法。你应该检查你的 JSON 的返回,并遍历你想要的值,然后从那里创建一个条件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-13
    • 2017-08-12
    • 2018-12-23
    • 1970-01-01
    相关资源
    最近更新 更多