【问题标题】:How to create the credential for Watson Machine Learning API to save a ML model如何为 Watson Machine Learning API 创建凭证以保存 ML 模型
【发布时间】:2021-03-04 09:18:30
【问题描述】:
from watson_machine_learning_client import WatsonMachineLearningAPIClient
wml_credentials = {
    "apikey" : "*****", # my own api key
    "url"    : "https://jp-tok.ml.cloud.ibm.com"
}
client = WatsonMachineLearningAPIClient( wml_credentials )

我根据 http://ibm-wml-api-pyclient.mybluemix.net/?_ga=2.133579662.1462677150.1614734898-1588850442.1613548438 编写了完全相同的代码,子主题:身份验证,以创建 Watson Machine Learning python 客户端实例来保存 ML 模型。

但我收到一个错误:

KeyError                                  Traceback (most recent call last)
<ipython-input-2-513e37fb8d9f> in <module>
      4     "url"    : "https://jp-tok.ml.cloud.ibm.com"
      5 }
----> 6 client = WatsonMachineLearningAPIClient( wml_credentials )

/opt/conda/envs/Python36/lib/python3.6/site-packages/watson_machine_learning_client/client.py in __init__(self, wml_credentials, project_id)
     40         if wml_credentials is None:
     41             raise NoWMLCredentialsProvided()
---> 42         if 'icp' == wml_credentials[u'instance_id'].lower():
     43             self.ICP = True
     44             os.environ["DEPLOYMENT_PLATFORM"] = "private"

KeyError: 'instance_id'

我可以做些什么来解决这个问题?网络上的内容表明

注意:没有要提供的 instance_id。 instance_id 将是 从新(v2)实例的关联空间/项目中拾取 计划。

【问题讨论】:

  • 文档说“APIClient”,您的示例是“WatsonMachineLearningAPIClient”。为什么?这就是所有代码吗?

标签: ibm-cloud ibm-watson


【解决方案1】:

您在代码中使用了已弃用的 WML Python 客户端版本。 导入latest package

from ibm_watson_machine_learning import APIClient

另外,使用新的 APIClient 对象代替已弃用的 WatsonMachineLearningClient

wml_credentials = {
    "apikey": "<your_wml_apikey>",
    "url": "<your_wml_endpoint_url>"
}
client = APIClient(wml_credentials)

【讨论】:

    猜你喜欢
    • 2019-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 2016-08-05
    相关资源
    最近更新 更多