選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

更新 Amazon Personalize 指標屬性 - Amazon Personalize

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

更新 Amazon Personalize 指標屬性

當您更新指標屬性時,您可以新增和移除指標,並修改其輸出組態。您可以使用 Amazon Personalize 主控台 AWS Command Line Interface或 AWS SDKS 更新指標屬性。

更新指標屬性 (主控台)

若要使用 Amazon Personalize 主控台更新指標屬性,請在指標屬性頁面上進行變更。

更新指標屬性
  1. https://console.aws.amazon.com/personalize/home:// 開啟 Amazon Personalize 主控台並登入您的帳戶。

  2. 選擇您的資料集群組。

  3. 在導覽窗格中,選擇指標屬性

  4. 在底部區段中,選擇指標屬性索引標籤或指標屬性組態索引標籤,以開始變更。

    • 若要新增或移除指標,請選擇指標屬性索引標籤,然後選擇編輯屬性。在編輯指標屬性頁面上進行變更,然後選擇更新以儲存變更。

    • 若要變更 Amazon S3 輸出儲存貯體或 IAM 服務角色,請選擇編輯指標屬性組態索引標籤,然後在編輯屬性組態頁面上進行變更。選擇 Update (更新) 以儲存您的設定。

更新指標屬性 (AWS CLI)

建立指標屬性之後,您可以使用 AWS Command Line Interface (AWS CLI) 來新增和移除指標,並修改其輸出組態。下列程式碼說明如何使用 update-metric-attribution命令移除指標:

aws personalize update-metric-attribution \ --metric-attribution-arn metric attribution arn \ --remove-metrics metricName1 metricName2

下列程式碼說明如何新增其他指標並指定新的輸出組態:

aws personalize update-metric-attribution \ --metric-attribution-arn metric attribution arn \ --metrics-output-config "{\"roleArn\": \"new role ARN\", \"s3DataDestination\":{\"kmsKeyArn\":\"kms key ARN\",\"path\":\"s3://amzn-s3-demo-bucket2/new-folder-name/\"}}" \ --add-metrics "[{ \"eventType\": \"event type\", \"expression\": \"SUM(DatasetType.COLUMN_NAME)\", \"metricName\": \"metric name\" }]"

如果成功,Amazon Personalize 會傳回您更新之指標屬性的 ARN。如需所有參數的完整清單,請參閱UpdateMetricAttribution

更新指標屬性 (AWS SDK)

建立指標屬性之後,您可以新增或移除指標,並修改其輸出組態。下列程式碼說明如何從指標屬性中移除指標。

SDK for Python (Boto3)
import boto3 personalize = boto3.client('personalize') metricsToRemove = ["metricName1", "metricName2"] response = personalize.update_metric_attribution( metricAttributionArn = "metric attribution ARN", removeMetrics = metricsToRemove )
SDK for Java 2.x
public static void removeMetrics(PersonalizeClient client, String metricAttributionArn, String metric1Name, String metric2Name) { ArrayList<String> metricsToRemove = new ArrayList<>(Arrays.asList(metric1Name, metric2Name)); try { UpdateMetricAttributionRequest request = UpdateMetricAttributionRequest.builder() .metricAttributionArn(metricAttributionArn) .removeMetrics(metricsToRemove) .build(); UpdateMetricAttributionResponse response = client.updateMetricAttribution(request); System.out.println(response); } catch (PersonalizeException e) { System.out.println(e.awsErrorDetails().errorMessage()); } }
SDK for JavaScript v3
// Get service clients and commands using ES6 syntax. import {UpdateMetricAttributionCommand, PersonalizeClient } from "@aws-sdk/client-personalize"; // create personalizeClient const personalizeClient = new PersonalizeClient({ region: "REGION" }); // set the update request param export const updateMetricAttributionParam = { metricAttributionArn: "METRIC_ATTRIBUTION_ARN", /* required */ removeMetrics: ["METRIC_NAME_1", "METRIC_NAME_2"] /* specify list of names of metrics to delete */ }; export const run = async () => { try { const response = await personalizeClient.send( new UpdateMetricAttributionCommand(updateMetricAttributionParam) ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
import boto3 personalize = boto3.client('personalize') metricsToRemove = ["metricName1", "metricName2"] response = personalize.update_metric_attribution( metricAttributionArn = "metric attribution ARN", removeMetrics = metricsToRemove )

下列程式碼說明如何新增其他指標並指定新的輸出組態:

SDK for Python (Boto3)
import boto3 personalize = boto3.client('personalize') newMetrics = [{ "eventType": "event type", "expression": "SUM(DatasetType.COLUMN_NAME)", "metricName": "metric name" }] newOutputConfig = { "roleArn": "Amazon Personalize service role ARN", "s3DataDestination": { "kmsKeyArn": "key ARN", "path": "s3://amzn-s3-demo-bucket/<folder>" } } response = personalize.update_metric_attribution( metricAttributionArn = "metric attribution arn", metricsOutputConfig = newOutputConfig, addMetrics = newMetrics )
SDK for Java 2.x
public static void addMetricsAndUpdateOutputConfig(PersonalizeClient personalizeClient, String metricAttributionArn, String newMetric1EventType, String newMetric1Expression, String newMetric1Name, String newMetric2EventType, String newMetric2Expression, String newMetric2Name, String roleArn, String s3Path, String kmsKeyArn) { try { MetricAttribute newAttribute = MetricAttribute.builder() .eventType(newMetric1EventType) .expression(newMetric1Expression) .metricName(newMetric1Name) .build(); MetricAttribute newAttribute2 = MetricAttribute.builder() .eventType(newMetric2EventType) .expression(newMetric2Expression) .metricName(newMetric2Name) .build(); ArrayList<MetricAttribute> newAttributes = new ArrayList<>(Arrays.asList(newAttribute, newAttribute2)); S3DataConfig newDataDestination = S3DataConfig.builder() .kmsKeyArn(kmsKeyArn) .path(s3Path) .build(); MetricAttributionOutput newOutputConfig = MetricAttributionOutput.builder() .roleArn(roleArn) .s3DataDestination(newDataDestination) .build(); UpdateMetricAttributionRequest request = UpdateMetricAttributionRequest.builder() .metricAttributionArn(metricAttributionArn) .metricsOutputConfig(newOutputConfig) .addMetrics(newAttributes) .build(); UpdateMetricAttributionResponse response = personalizeClient.updateMetricAttribution(request); System.out.println("New metrics added!"); System.out.println(response); } catch (PersonalizeException e) { System.out.println(e.awsErrorDetails().errorMessage()); } }
SDK for JavaScript v3
// Get service clients and commands using ES6 syntax. import {UpdateMetricAttributionCommand, PersonalizeClient } from "@aws-sdk/client-personalize"; // create personalizeClient const personalizeClient = new PersonalizeClient({ region: "REGION" }); export const updateMetricAttributionParam = { metricAttributionArn: "METRIC_ATTRIBUTION_ARN", addMetrics: [ { eventType: "EVENT_TYPE", /* required for each metric */ expression: "SUM(DatasetType.COLUMN_NAME)", /* required for each metric */ metricName: "METRIC_NAME", /* required for each metric */ } ], metricsOutputConfig: { roleArn: "ROLE_ARN", /* required */ s3DataDestination: { kmsKeyArn: "KEY_ARN", /* optional */ path: "s3://amzn-s3-demo-bucket/<folderName>/", /* optional */ }, } }; export const run = async () => { try { const response = await personalizeClient.send( new UpdateMetricAttributionCommand(updateMetricAttributionParam) ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
import boto3 personalize = boto3.client('personalize') newMetrics = [{ "eventType": "event type", "expression": "SUM(DatasetType.COLUMN_NAME)", "metricName": "metric name" }] newOutputConfig = { "roleArn": "Amazon Personalize service role ARN", "s3DataDestination": { "kmsKeyArn": "key ARN", "path": "s3://amzn-s3-demo-bucket/<folder>" } } response = personalize.update_metric_attribution( metricAttributionArn = "metric attribution arn", metricsOutputConfig = newOutputConfig, addMetrics = newMetrics )

如果成功,Amazon Personalize 會傳回您更新之指標屬性的 ARN。如需所有參數的完整清單,請參閱UpdateMetricAttribution

隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。