

自 2025 年 11 月 7 日起，Amazon Fraud Detector 不再向新客戶開放。對於類似 Amazon Fraud Detector 的功能，請探索 Amazon 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 API 或使用 來新增或更新預存事件的標籤 [UpdateEventLabel](https://docs.aws.amazon.com/frauddetector/latest/api/API_UpdateEventLabel.html) 適用於 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 主控台中使用 [delete-label](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：//[https://console.aws.amazon.com/frauddetector](https://console.aws.amazon.com/frauddetector) 的 Amazon Fraud Detector 主控台。

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'
)
```