【问题标题】:Python Google Prediction examplePython 谷歌预测示例
【发布时间】:2020-11-30 01:43:50
【问题描述】:
predict_custom_model_sample(
    "projects/794xxx496/locations/us-central1/xxxx/3452xxx524447744",
    { "instance_key_1": "value", ... },
    { "parameter_key_1": "value", ... }
)

Google 给出了这个例子,我不理解 parameter_key 和 instance_key。据我了解,我需要发送 JSON 实例。

{"instances": [  {"when": {"price": "1212"}}]}

如何使其与 predict_custom_model_sample 一起使用?

【问题讨论】:

    标签: google-cloud-ml google-prediction


    【解决方案1】:

    我假设你正在尝试这个codelab
    请注意,定义的函数名 (predict_tabular_model) 和使用的函数名 (predict_custom_model_sample) 之间似乎不匹配。

    INSTANCES 是一个包含一个或多个任意类型的 JSON 值的数组。每个值代表一个您为其提供预测的实例。
    Instant_key_1 只是进入实例的键/值的第一个键。

    同样,parameter_key_1 只是进入参数 JSON 对象的键/值的第一个键。
    如果您的模型使用自定义容器,则您的输入必须格式化为 JSON,并且还有一个额外的参数字段可用于您的容器。

    PARAMETERS 是一个 JSON 对象,其中包含容器所需的任何参数,以帮助对实例进行预测。 AI Platform 认为参数字段是可选的,因此您可以将容器设计为需要它、仅在提供时使用或忽略它。

    参考:https://cloud.google.com/ai-platform-unified/docs/predictions/custom-container-requirements#request_requirements

    Here您有来自自定义训练模型的在线预测输入示例

    对于codelab,我相信你可以使用提供的示例:

    test_instance={
        'Time': 80422,
        'Amount': 17.99,
    …
    }
    

    然后调用预测(记得在上面的笔记本单元格中检查函数名称)

    predict_custom_model_sample(
       "your-endpoint-str",
        test_instance
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      • 2020-03-28
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      • 2016-01-31
      • 1970-01-01
      相关资源
      最近更新 更多