我正在试验 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"
}
我非常确定该模型正在接收这些更新。 get
和 analyze
都显示该模型有 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/