您可以更新特征组,以将 BigQuery 表或视图注册为该特征组的特征数据源。如果特征组已具有关联的数据源,则可以关联另一个 BigQuery 表或视图作为特征数据源。
创建或更新特征组时,您可以选择以标签形式向特征组添加用户定义的元数据。如需详细了解如何更新特征组的用户定义标签,请参阅更新特征组的标签。
准备工作
向 Vertex AI 进行身份验证,除非您已完成此操作。
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭证。
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证。
更新特征组
使用以下示例可更新特征组。
REST
如需更新 FeatureGroup
资源,请使用 featureGroups.patch 方法发送 PATCH
请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:特征组所在的区域,例如
us-central1
。 - PROJECT_ID:您的项目 ID。
- FEATURE_GROUP_NAME:您要更新的特征组的名称。
- ENTITY_ID_COLUMNS:包含实体 ID 的列名称。您可以指定一列或多列。
- 如需仅指定一个实体 ID 列,请按以下格式指定列名称:
"entity_id_column_name"
。 - 如需指定多个实体 ID 列,请按以下格式指定列名称:
["entity_id_column_1_name", "entity_id_column_2_name", ...]
。
- 如需仅指定一个实体 ID 列,请按以下格式指定列名称:
- BIGQUERY_SOURCE_URI:您要与特征组关联的 BigQuery 源表或视图的 URI。
HTTP 方法和网址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATURE_GROUP_NAME
请求 JSON 正文:
{ "big_query": { "entity_id_columns": "ENTITY_ID_COLUMNS", "big_query_source": { "input_uri": "BIGQUERY_SOURCE_URI" } } }
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATURE_GROUP_NAME"
PowerShell
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups?feature_group_id=FEATURE_GROUP_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATURE_GROUP_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureGroupOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T03:00:13.060636Z", "updateTime": "2023-09-18T03:00:13.060636Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureGroup", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATURE_GROUP_NAME" } }