您可以更新特徵群組,將 BigQuery 資料表或檢視表註冊為該特徵群組的特徵資料來源。如果特徵群組已建立關聯的資料來源,您可以將不同的 BigQuery 資料表或檢視表做為特徵資料來源。
建立或更新特徵群組時,您可以選擇以標籤的形式,將使用者定義的中繼資料新增至特徵群組。如要進一步瞭解如何更新特徵群組的使用者定義標籤,請參閱「更新特徵群組的標籤」。
事前準備
向 Vertex AI 進行驗證 (如果尚未完成)。
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it 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 驗證說明文件中的「Authenticate for using 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" } }