当我尝试测试成功部署的ML模型时,为什么会出现“无效数据输入”错误?

时间:2019-01-07 22:12:39

标签: machine-learning ibm-cloud ibm-watson

我遵循了一个示例笔记本,使用scikit-learn创建了IBM云机器学习模型。教程can be found here

每个单元都正确运行,并且模型已成功部署,但是当我单击模型并尝试进行预测时,将显示错误“无效的输入数据”。为什么会发生此问题,我该如何解决?

enter image description here

wml_credentials = {
  "username": "****",
  "password": "****",
  "instance_id": "****",
  "url": "https://ibm-watson-ml.mybluemix.net”
}

创建API客户端时,我尝试将url"https://ibm-watson-ml.mybluemix.net”更改为"https://us-south.ml.cloud.ibm.com”

我还尝试过添加访问密钥,例如:

wml_credentials = {
  "access_key”: "****",
  "username": "****",
  "password": "****",
  "instance_id": "****",
  "url": "https://ibm-watson-ml.mybluemix.net”
}

没有帮助。

1 个答案:

答案 0 :(得分:0)

您可以将输入作为JSON传递,如下所示,而不是传递f0,f1,f2 .....的各个值

{
  "fields" : [ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39", "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47", "f48", "f49", "f50", "f51", "f52", "f53", "f54", "f55", "f56", "f57", "f58", "f59", "f60", "f61", "f62", "f63" ],
  "values" : [ [ 0.0, 5.0, 12.0, 13.0, 16.0, 16.0, 2.0, 0.0, 0.0, 11.0, 16.0, 15.0, 8.0, 4.0, 0.0, 0.0, 0.0, 8.0, 14.0, 11.0, 1.0, 0.0, 0.0, 0.0, 0.0, 8.0, 16.0, 16.0, 14.0, 0.0, 0.0, 0.0, 0.0, 1.0, 6.0, 6.0, 16.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 16.0, 3.0, 0.0, 0.0, 0.0, 1.0, 5.0, 15.0, 13.0, 0.0, 0.0, 0.0, 0.0, 4.0, 15.0, 16.0, 2.0, 0.0, 0.0, 0.0 ] ]
}

附加是有关如何在部署过程中传递JSON输入的屏幕截图

enter image description here

我刚刚验证了笔记本,您不必更改ML URL。