您可以透過下列方式,從實體類型中刪除特徵值:
從指定實體刪除特徵值
您可以刪除實體類型中多個實體的特徵值。如要指定要刪除特徵值的實體,請在 CSV 檔案中列出實體 ID。
REST
如要刪除特徵值,請使用 featurestores.entityTypes.deleteFeatureValues 方法傳送 POST 要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:建立特徵商店的區域或位置。例如:
us-central1
。 - PROJECT_ID:您的專案 ID。
- FEATURESTORE_ID:特徵商店的 ID。
- ENTITY_TYPE:要刪除特徵值的實體類型 ID。
- CSV_FILE_URI:指定 CSV 檔案的 Cloud Storage URI,其中包含要刪除特徵值的實體 ID。這個檔案的第一行應為下列其中一項:
- 如果指定
entity_id_field
參數,CSV 檔案的第一行必須與 ENTITY_ID_FIELD 相同。 - 如未指定
entity_id_field
參數,CSV 檔案的第一行必須是「entity_id」。
- 如果指定
- ENTITY_ID_FIELD:(選用) 在 CSV_FILE_URI 輸入 CSV 檔案第一行指定的字串。
HTTP 方法和網址:
POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE:deleteFeatureValues
JSON 要求主體:
{ "selectEntity": { "entityIdSelector": { "csv_source": { "gcs_source": { "uris": [ "CSV_FILE_URI" ] }, "entity_id_field": "ENTITY_ID_FIELD" } } } }
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
curl -X POST \
-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/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE:deleteFeatureValues"
PowerShell
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-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/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE:deleteFeatureValues" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "name": "projects/571445526053/locations/us-central1/operations/7688824614775947264", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteFeatureValuesOperationMetadata", "genericMetadata": { "createTime": "2022-05-09T16:59:38.128375Z", "updateTime": "2022-05-09T16:59:38.128375Z", "state": "RUNNING", "worksOn": [ "projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID" ] } } }
查看要求狀態
如要檢查 POST 要求的狀態,請傳送下列 GET 要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:建立特徵商店的區域或位置。例如:
us-central1
。 - OPERATION_NAME:透過 POST 要求刪除特徵值時,JSON 回應中 `name` 欄位的值。
HTTP 方法和網址:
GET https://LOCATION_ID-aiplatform.googleapis.com/v1/OPERATION_NAME
如要傳送要求,請選擇以下其中一個選項:
curl
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/OPERATION_NAME"
PowerShell
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/OPERATION_NAME" | Select-Object -Expand Content
您應該會收到執行成功的狀態碼 (2xx) 和空白回應。
刪除指定時間範圍內特定特徵的特徵值
您可以指定特徵 ID 和時間範圍,從實體類型中刪除特徵值。
REST
如要從實體類型刪除特徵值,請使用 featurestores.entityTypes.deleteFeatureValues 方法傳送 POST 要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:建立特徵商店的區域或位置。例如:
us-central1
。 - PROJECT_ID:您的專案 ID。
- FEATURESTORE_ID:特徵商店的 ID。
- ENTITY_TYPE:要刪除特徵值的實體類型 ID。
- START_TIME:指定時間範圍的開始時間。
- END_TIME:(選用) 指定時間範圍的結束時間。
- SKIP_ONLINE_STORAGE_DELETE:(選用) 如要從線上和離線儲存空間刪除特徵值,請輸入
false
。否則,如要只從離線儲存空間刪除特徵值,請輸入true
。
HTTP 方法和網址:
POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE:deleteFeatureValues
JSON 要求主體:
{ "selectTimeRangeAndFeature": { "timeRange": { "startTime": "START_TIME", "endTime": "END_TIME" }, "featureSelector": { "idMatcher": { "ids": [ "FEATURE_ID", ...] } }, "skipOnlineStorageDelete": SKIP_ONLINE_STORAGE_DELETE } }
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
curl -X POST \
-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/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE:deleteFeatureValues"
PowerShell
將要求主體儲存在名為 request.json
的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-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/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE:deleteFeatureValues" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "name": "projects/571445526053/locations/us-central1/operations/7688824614775947264", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteFeatureValuesOperationMetadata", "genericMetadata": { "createTime": "2022-05-09T16:59:38.128375Z", "updateTime": "2022-05-09T16:59:38.128375Z", "state": "RUNNING", "worksOn": [ "projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID" ] } } }
查看要求狀態
如要檢查 POST 要求的狀態,請傳送下列 GET 要求。
使用任何要求資料之前,請先替換以下項目:
- LOCATION_ID:建立特徵商店的區域或位置。例如:
us-central1
。 - OPERATION_NAME:透過 POST 要求刪除特徵值時,JSON 回應中 `name` 欄位的值。
HTTP 方法和網址:
GET https://LOCATION_ID-aiplatform.googleapis.com/v1/OPERATION_NAME
如要傳送要求,請選擇以下其中一個選項:
curl
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/OPERATION_NAME"
PowerShell
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/OPERATION_NAME" | Select-Object -Expand Content
您應該會收到執行成功的狀態碼 (2xx) 和空白回應。