在特徵群組中,您可以更新特徵,將其與 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
如要更新 Feature
資源,請使用 features.patch 方法傳送 PATCH
要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:含有特徵的特徵群組所在區域,例如
us-central1
。 - PROJECT_ID:您的專案 ID。
- FEATURE_GROUP_NAME:包含特徵的特徵群組名稱。
- FEATURE_NAME:要更新的功能名稱。
- VERSION_COLUMN_NAME:更新功能時要建立關聯的 BigQuery 來源資料表或檢視畫面中的資料欄。
HTTP 方法和網址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATURE_GROUP_NAME/features?feature_id=FEATURE_NAME
JSON 要求主體:
{ "version_column_name": "VERSION_COLUMN_NAME" }
如要傳送要求,請選擇以下其中一個選項:
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/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATURE_GROUP_NAME/features?feature_id=FEATURE_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/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATURE_GROUP_NAME/features?feature_id=FEATURE_NAME" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATURE_GROUP_NAME/features/FEATURE_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1beta1.UpdateFeatureOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T02:36:22.870679Z", "updateTime": "2023-09-18T02:36:22.870679Z" } }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1beta1.Feature", "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATURE_GROUP_NAME/features/FEATURE_NAME" } }