ruby - 更新对分数没有影响(预测 API)

标签 ruby google-prediction

我正在试验 Google 预测示例中的 language_id.txt 数据集。现在我正在尝试使用以下方法更新模型:

def update(label, data)
  input = @prediction.trainedmodels.update.request_schema.new
  input.label = label
  input.csv_instance = [data]
  result = @client.execute(
    :api_method => @prediction.trainedmodels.update,
    :parameters => {'id' => MODEL_ID},
    :headers => {'Content-Type' => 'application/json'},
    :body_object => input
  )
  assemble_json_body(result)
end

(此方法基于一些Google sample code .)

我的问题是这些更新没有效果。以下是 This is a test sentence. 的分数,无论我运行了多少次更新:

{
   "response":{
      "kind":"prediction#output",
      "id":"mymodel",
      "selfLink":"https://www.googleapis.com/prediction/v1.5/trainedmodels/mymodel/predict",
      "outputLabel":"English",
      "outputMulti":[
         {
            "label":"English",
            "score":0.420937
         },
         {
            "label":"French",
            "score":0.273789
         },
         {
            "label":"Spanish",
            "score":0.305274
         }
      ]
   },
   "status":"success"
}

根据“Creating a Sentiment Analysis Model”底部的免责声明,我已确保至少更新 100 次才能期待任何更改。首先,我尝试使用一个句子并将其更新 1000 次。其次,我尝试使用从 Simple Wikipedia 中提取的约 150 个独特的句子,并分别更新一次。每次更新都“成功”:

{"response":{"kind":"prediction#training","id":"mymodel","selfLink":"https://www.googleapis.com/prediction/v1.5/trainedmodels/mymodel"},"status":"success"}

但这两种方法都没有改变我的结果。

我还尝试过使用 APIs Explorer(Prediction,v1.5)并以这种方式更新约 300 次。我的结果仍然没有区别。这些更新也“成功”了。

200 OK
{
"kind": "prediction#training",
"id": "mymodel",
"selfLink": "https://www.googleapis.com/prediction/v1.5/trainedmodels/mymodel"
}

我非常确定该模型正在接收这些更新。 getanalyze 都显示该模型有 numberInstances": "2024"。但奇怪的是,list 显示该模型有 "numberInstances": "406"

目前,我不知道是什么导致了这个问题。

最佳答案

2019 年更新

根据 Jochem Schulenklopper 的评论,该 API 已于 2018 年 4 月关闭。

Developers who choose to move to the Google Cloud Machine Learning Engine will have to recreate their existing Prediction API models.

机器学习 API 示例: https://github.com/GoogleCloudPlatform/cloudml-samples

关于ruby - 更新对分数没有影响(预测 API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11233740/

相关文章:

ruby - Rails 3.0.12 性能测试问题

ruby - Ruby 模板中的 Jade 风格 block (Haml?)

tensorflow - ML-Engine 预测出现错误,但本地预测工作正常

python - "TypeError: cannot instantiate ctype ' EVP_MD_CTX ' of unknown size"在尝试构建 google 预测 api 时

machine-learning - Google 预测 CSV 最大大小?

ruby-on-rails - 在 Rails Controller 中使用错误的命名空间

ruby - 如何遍历 popen 输出?

ruby - 我应该试验什么算法来尝试对这些 PDF 进行分类?

machine-learning - Google 预测 api,将输出作为具有可变大小的列表

algorithm - Google Hangout算法预测面部 Action