

截至 2025 年 11 月 7 日，亚马逊 Fraud Detector 不再向新客户开放。要获得与 Amazon Fraud Detector 类似的功能 SageMaker，请浏览亚马逊 AutoGluon、和 AWS WAF。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 标签
<a name="labels"></a>

标签将事件归类为欺诈事件或合法事件。标签与事件类型相关联，用于在 Amazon Fraud Detector 中训练机器学习模型。*如果您计划训练在线欺诈洞察 (OFI) 或交易欺诈洞察 (TFI) 模型，则必须将训练数据集中至少 400 个事件归类为欺*诈*事件或合法事件。*您可以使用任何标签（例如*欺诈*、*合法*、*1* 或 *0*）对训练数据集中的事件进行分类。训练完成后，经过训练的模型会评估欺诈事件，并使用这些值将事件归类为欺诈事件或合法事件。

您必须先使用训练数据集中使用的值创建标签，然后将这些标签与用于构建和训练欺诈检测模型的事件类型相关联。

# 创建标签
<a name="create-a-label"></a>

您可以在 Amazon Fraud Detector 控制台中创建[标签，使用 put-label](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/frauddetector/put-label.html) 命令，使用 [PutLabel](https://docs.aws.amazon.com/frauddetector/latest/api/API_PutLabel.html)API 或使用。 适用于 Python (Boto3) 的 AWS SDK

## 使用 Amazon Fraud Detector 控制台创建标签
<a name="create-a-label-console"></a>

**要创建标签，**

1. 打开 [AWS 管理控制台](https://console.aws.amazon.com/)，登录您的账户。

1. 导航至 Amazon Fraud Detector，在左侧导航栏中选择 “**标签**”，然后选择 “**创建**”。

1. 在 “**创建标签**” 页面中，输入欺诈事件的标签名称作为标签名称。标签名称必须与训练数据集中代表欺诈活动的标签相对应。（可选）输入标签的描述。

1. 选择**创建标签**。

1. 创建第二个标签并输入合法事件的标签名称。确保标签名称与代表训练数据集中合法活动的值相对应。

## 使用创建标签 适用于 Python (Boto3) 的 AWS SDK
<a name="create-a-label-using-the-aws-python-sdk"></a>

以下 适用于 Python (Boto3) 的 AWS SDK 示例代码使用 [PutLabel](https://docs.aws.amazon.com/frauddetector/latest/api/API_PutLabel.html)API 创建了两个标签（欺诈、合法）。创建标签后，您可以将其添加到事件类型中以对特定事件进行分类。

```
import boto3
fraudDetector = boto3.client('frauddetector')

fraudDetector.put_label(
name = 'fraud',
description = 'label for fraud events'
)

fraudDetector.put_label(
name = 'legit',
description = 'label for legitimate events'
)
```

# 更新标签
<a name="update-label"></a>

如果您的事件数据集存储在 Amazon Fraud Detector 中，则可能需要为存储的事件添加或更新标签，例如当您对事件进行离线欺诈调查并想要关闭机器学习反馈循环时。

 您可以使用[update-event-label](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/frauddetector/update-event-label.html)命令、[UpdateEventLabel](https://docs.aws.amazon.com/frauddetector/latest/api/API_UpdateEventLabel.html)API 或使用，为存储的事件添加或更新标签 适用于 Python (Boto3) 的 AWS SDK 

以下 适用于 Python (Boto3) 的 AWS SDK 示例代码添加了一个标签*欺诈*，该标签与使用 `UpdateEventLabel` API *注册*的事件类型相关联。

```
import boto3
fraudDetector = boto3.client('frauddetector')

fraudDetector.update_event_label(
            eventId        = '802454d3-f7d8-482d-97e8-c4b6db9a0428',
            eventTypeName  = 'registration',
            assignedLabel  = 'fraud',
            labelTimestamp = '2020-07-13T23:18:21Z'
)
```

# 更新存储在 Amazon Fraud Detector 中的事件数据中的事件标签
<a name="update-event-labels"></a>

对于已经存储在 Amazon Fraud Detector 中的事件，您可能需要添加或更新欺诈标签，例如当您对某个事件进行离线欺诈调查并想要关闭机器学习反馈循环时。要更新已存储在 Amazon Fraud Detector 中的事件的标签，请使用 `UpdateEventLabel` API 操作。以下显示了 UpdateEventLabel API 调用的示例。

```
import boto3
fraudDetector = boto3.client('frauddetector')

fraudDetector.update_event_label(
            eventId        = '802454d3-f7d8-482d-97e8-c4b6db9a0428',
            eventTypeName  = 'sample_registration',
            assignedLabel  = 'fraud',
            labelTimestamp = '2020-07-13T23:18:21Z'
)
```

# 删除标签
<a name="delete-label"></a>

当您删除标签时，Amazon Fraud Detector 会永久删除该标签，并且数据将不再存储在 Amazon Fraud Detector 中。

您无法删除 Amazon Fraud Detector 事件类型中包含的标签。而且您也无法删除分配给事件 ID 的标签。必须先删除相关的事件 ID。

您可以在 Amazon Fraud Detector 控制台中[删除标签，使用删除标签](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/frauddetector/delete-label.html)命令，使用 [DeleteLabel](https://docs.aws.amazon.com/frauddetector/latest/api/API_DeleteLabel.html)API 或使用 适用于 Python (Boto3) 的 AWS SDK

## 使用控制台删除标签
<a name="delete-label-console"></a>

**删除标签**

1. 登录 AWS 管理控制台 并在 [https://console.aws.amazon.com/frauddetector 上打开 Amazon Fraud Detector](https://console.aws.amazon.com/frauddetector) 控制台。

1. 在 Amazon Fraud Detector 控制台的左侧导航窗格中，选择**资源**，然后选择**标签**。

1. 选择要删除的标签。

1. 选择**操作**，然后选择**删除**。

1. 输入标签名称，然后选择**删除标签**。

## 使用删除标签 适用于 Python (Boto3) 的 AWS SDK
<a name="delete-label-using-the-aws-python-sdk"></a>

以下 适用于 Python (Boto3) 的 AWS SDK 示例代码使用 [DeleteLabel](https://docs.aws.amazon.com/frauddetector/latest/api/API_DeleteLabel.html)API 删除*了合法*标签。

```
import boto3
fraudDetector = boto3.client('frauddetector')

fraudDetector.delete_event_label (
    name = 'legit'
)
```