首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为顶点AI模型评估生成实例和预测模式文件(Google管道组件)

为顶点AI模型评估生成实例和预测模式文件(Google管道组件)
EN

Stack Overflow用户
提问于 2022-10-06 22:41:08
回答 2查看 102关注 0票数 2

我构建了一个自定义模型,并尝试使用Google管道组件在顶点AI上进行模型评估。根据评量笔记本示例,我需要准备instance_schema.yaml和prediction_schema.yaml来导入非托管模型。

那么如何以编程方式生成实例和预测模式文件呢?

EN

回答 2

Stack Overflow用户

发布于 2022-10-31 19:44:43

对于自定义模型,不需要实例和预测模式:

代码语言:javascript
复制
"predictSchemata": {
    "predictionSchemaUri": MODEL_URI + "/prediction_schema.yaml",
    "instanceSchemaUri": MODEL_URI + "/instance.yaml",
},
票数 0
EN

Stack Overflow用户

发布于 2022-11-11 05:48:08

简言之:

现在,要以编程方式进行构建,这取决于您的用例和您从何处开始。我确信从源数据构建自己的yaml内容是可行的。在我的例子中,我构建了我的自定义映像来使用勾股模型运行我的预测器,您可以从该映像中自动生成json格式的openapi模式,然后将其转换为yaml文件。使用与您不同的数据集(我使用的是寿司数据集),我的代码示例如下:

代码语言:javascript
复制
import yaml
from pydantic import BaseModel, Field


class InstanceModel(BaseModel):
    age: int = Field(..., ge=0, le=5)
    east_west_id_now: int = Field(..., ge=0, le=1)
    east_west_id_until_15yo: int = Field(..., ge=0, le=1)
    gender: int = Field(..., ge=0, le=1)
    prefecture_id_now: int = Field(..., ge=0, le=47)
    prefecture_id_until_15yo: int = Field(..., ge=0, le=47)
    region_id_now: int = Field(..., ge=0, le=11)
    region_id_until_15yo: int = Field(..., ge=0, le=11)
    same_prefecture_id_over_time: int = Field(..., ge=0, le=1)
    time_fill_form: int = Field(..., ge=0)

schema_file_path = "..." #  where you want your yaml file
model_json_string = InstanceModel.schema_json()
model_dict = json.loads(model_json_string)
example = {}
for key in model_dict['properties']:
    example[key] = 0
model_dict['example'] = example
with open(schema_file_path, 'w', encoding='utf8') as f:
    yaml.dump(model_dict, f)

它创建了以下内容:

代码语言:javascript
复制
example:
  age: 0
  east_west_id_now: 0
  east_west_id_until_15yo: 0
  gender: 0
  prefecture_id_now: 0
  prefecture_id_until_15yo: 0
  region_id_now: 0
  region_id_until_15yo: 0
  same_prefecture_id_over_time: 0
  time_fill_form: 0
properties:
  age:
    maximum: 5
    minimum: 0
    title: Age
    type: integer
  east_west_id_now:
    maximum: 1
    minimum: 0
    title: East West Id Now
    type: integer
  east_west_id_until_15yo:
    maximum: 1
    minimum: 0
    title: East West Id Until 15Yo
    type: integer
  gender:
    maximum: 1
    minimum: 0
    title: Gender
    type: integer
  prefecture_id_now:
    maximum: 47
    minimum: 0
    title: Prefecture Id Now
    type: integer
  prefecture_id_until_15yo:
    maximum: 47
    minimum: 0
    title: Prefecture Id Until 15Yo
    type: integer
  region_id_now:
    maximum: 11
    minimum: 0
    title: Region Id Now
    type: integer
  region_id_until_15yo:
    maximum: 11
    minimum: 0
    title: Region Id Until 15Yo
    type: integer
  same_prefecture_id_over_time:
    maximum: 1
    minimum: 0
    title: Same Prefecture Id Over Time
    type: integer
  time_fill_form:
    minimum: 0
    title: Time Fill Form
    type: integer
required:
- age
- east_west_id_now
- east_west_id_until_15yo
- gender
- prefecture_id_now
- prefecture_id_until_15yo
- region_id_now
- region_id_until_15yo
- same_prefecture_id_over_time
- time_fill_form
title: InstanceModel
type: object

现在我的问题是我不知道它在哪里被使用..。我在控制台的模型版本/详细信息/请求示例中看不到它.所以在那之后我可能做错了什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73980694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档