训练和测试旨在检测洗钱行为的模型

了解如何使用开发机器上或 Google Cloud 控制台中的命令行工具执行反洗钱 AI 中的基本操作。

在本指南中,您将以 BigQuery 表的形式提供示例银行交易数据,作为 AML AI 的输入。API 会输出包含回测结果和预测结果的 BigQuery 表。其结果用于分析通过组织资金结构进行洗钱的示例方。

准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud 新手,请创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
  2. 安装 Google Cloud CLI。
  3. 如需初始化 gcloud CLI,请运行以下命令:

    gcloud init
  4. 创建或选择 Google Cloud 项目

    • 创建 Google Cloud 项目:

      gcloud projects create PROJECT_ID

      PROJECT_ID 替换为您要创建的 Google Cloud 项目的名称。

    • 选择您创建的 Google Cloud 项目:

      gcloud config set project PROJECT_ID

      PROJECT_ID 替换为您的 Google Cloud 项目 名称。

  5. 确保您的 Google Cloud 项目已启用结算功能

  6. Enable the required APIs:

    gcloud services enable financialservices.googleapis.com bigquery.googleapis.com cloudkms.googleapis.com bigquerydatatransfer.googleapis.com
  7. 为您的 Google 账号创建本地身份验证凭据:

    gcloud auth application-default login
  8. 向您的 Google 账号授予角色。对以下每个 IAM 角色运行以下命令一次: roles/financialservices.admin

    gcloud projects add-iam-policy-binding PROJECT_ID --member="user:EMAIL_ADDRESS" --role=ROLE
    • PROJECT_ID 替换为您的项目 ID。
    • EMAIL_ADDRESS 替换为您的电子邮件地址。
    • ROLE 替换为每个角色。
  9. 安装 Google Cloud CLI。
  10. 如需初始化 gcloud CLI,请运行以下命令:

    gcloud init
  11. 创建或选择 Google Cloud 项目

    • 创建 Google Cloud 项目:

      gcloud projects create PROJECT_ID

      PROJECT_ID 替换为您要创建的 Google Cloud 项目的名称。

    • 选择您创建的 Google Cloud 项目:

      gcloud config set project PROJECT_ID

      PROJECT_ID 替换为您的 Google Cloud 项目 名称。

  12. 确保您的 Google Cloud 项目已启用结算功能

  13. Enable the required APIs:

    gcloud services enable financialservices.googleapis.com bigquery.googleapis.com cloudkms.googleapis.com bigquerydatatransfer.googleapis.com
  14. 为您的 Google 账号创建本地身份验证凭据:

    gcloud auth application-default login
  15. 向您的 Google 账号授予角色。对以下每个 IAM 角色运行以下命令一次: roles/financialservices.admin

    gcloud projects add-iam-policy-binding PROJECT_ID --member="user:EMAIL_ADDRESS" --role=ROLE
    • PROJECT_ID 替换为您的项目 ID。
    • EMAIL_ADDRESS 替换为您的电子邮件地址。
    • ROLE 替换为每个角色。
  16. 为便于完成本指南,本指南中的 API 请求使用相同的 Google Cloud 项目和位置以及硬编码的资源 ID。资源 ID 遵循 my-resource-type 格式(例如 my-key-ringmy-model)。

    确保为本指南定义了以下替换内容:

    • PROJECT_IDIAM 设置中列出的 Google Cloud 项目 ID
    • PROJECT_NUMBER:与 PROJECT_ID 关联的项目编号。您可以在 IAM 设置页面上找到项目编号。
    • LOCATION:API 资源的位置;请使用受支持的区域之一:
      • us-central1
      • us-east1
      • asia-south1
      • europe-west1
      • europe-west2
      • europe-west4
      • northamerica-northeast1
      • southamerica-east1

创建实例

本部分介绍如何创建实例。AML AI 实例位于所有其他 AML AI 资源的根目录下。每个实例都需要一个关联的客户管理的加密密钥 (CMEK),该密钥用于加密 AML AI 创建的任何数据。

创建密钥环

如需创建密钥环,请使用 projects.locations.keyRings.create 方法。

REST

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings?key_ring_id=my-key-ring"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings?key_ring_id=my-key-ring" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring",
  "createTime": CREATE_TIME
}

gcloud

执行以下命令:

Linux、macOS 或 Cloud Shell

gcloud kms keyrings create my-key-ring \
  --location LOCATION

Windows (PowerShell)

gcloud kms keyrings create my-key-ring `
  --location LOCATION

Windows (cmd.exe)

gcloud kms keyrings create my-key-ring ^
  --location LOCATION
您应该会收到一个空响应:
$

创建密钥

如需创建密钥,请使用 projects.locations.keyRings.cryptoKeys 方法。

REST

请求 JSON 正文:

{
  "purpose": "ENCRYPT_DECRYPT"
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
  "purpose": "ENCRYPT_DECRYPT"
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys?crypto_key_id=my-key"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
  "purpose": "ENCRYPT_DECRYPT"
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys?crypto_key_id=my-key" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys/my-key",
  "primary": {
    "name": "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys/my-key/cryptoKeyVersions/1",
    "state": "ENABLED",
    "createTime": CREATE_TIME,
    "protectionLevel": "SOFTWARE",
    "algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION",
    "generateTime": GENERATE_TIME
  },
  "purpose": "ENCRYPT_DECRYPT",
  "createTime": CREATE_TIME,
  "versionTemplate": {
    "protectionLevel": "SOFTWARE",
    "algorithm": "GOOGLE_SYMMETRIC_ENCRYPTION"
  },
  "destroyScheduledDuration": "86400s"
}

gcloud

在使用下面的命令数据之前,请先进行以下替换:

  • LOCATION:密钥环的位置;请使用受支持的区域之一:
    • us-central1
    • us-east1
    • asia-south1
    • europe-west1
    • europe-west2
    • europe-west4
    • northamerica-northeast1
    • southamerica-east1

执行以下命令:

Linux、macOS 或 Cloud Shell

gcloud kms keys create my-key \
  --keyring my-key-ring \
  --location LOCATION \
  --purpose "encryption"

Windows (PowerShell)

gcloud kms keys create my-key `
  --keyring my-key-ring `
  --location LOCATION `
  --purpose "encryption"

Windows (cmd.exe)

gcloud kms keys create my-key ^
  --keyring my-key-ring ^
  --location LOCATION ^
  --purpose "encryption"
您应该会收到一个空响应:
$

使用 API 创建实例

如需创建实例,请使用 projects.locations.instances.create 方法。

请求 JSON 正文:

{
  "kmsKey": "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys/my-key"
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
  "kmsKey": "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys/my-key"
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances?instance_id=my-instance"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
  "kmsKey": "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys/my-key"
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances?instance_id=my-instance" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

如果成功,响应正文会包含一个长时间运行的操作,其中包含可用于检索异步操作的正在进行状态的 ID。复制返回的 OPERATION_ID 以便在下一部分中使用。

查看结果

使用 projects.locations.operations.get 方法检查是否已创建实例。如果响应包含 "done": false,请重复该命令,直到响应包含 "done": true

本指南中的操作可能需要几分钟到几小时才能完成。在本指南中,您必须等到某项操作完成后才能继续操作,因为 API 会将某些方法的输出用作其他方法的输入。

在使用任何请求数据之前,请先进行以下替换:

  • OPERATION_ID:操作的标识符

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "endTime": END_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.Instance",
    "name": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance",
    "createTime": CREATE_TIME,
    "updateTime": UPDATE_TIME,
    "kmsKey": "projects/KMS_PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys/my-key",
    "state": "ACTIVE"
  }
}

授予对 CMEK 密钥的访问权限

API 会自动在您的项目中创建一个服务帐号。服务帐号需要访问 CMEK 密钥,才能使用该密钥加密和解密基础数据。授予对密钥的访问权限。

gcloud kms keys add-iam-policy-binding "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring/cryptoKeys/my-key" \
  --keyring "projects/PROJECT_ID/locations/LOCATION/keyRings/my-key-ring" \
  --location "LOCATION" \
  --member "serviceAccount:service-PROJECT_NUMBER@gcp-sa-financialservices.iam.gserviceaccount.com" \
  --role="roles/cloudkms.cryptoKeyEncrypterDecrypter" \
  --project="PROJECT_ID"

创建 BigQuery 数据集

本部分介绍如何创建输入和输出 BigQuery 数据集,然后将示例银行数据复制到输入数据集中。

创建输出数据集

运行以下命令创建数据集,该数据集用于向其发送 AML 流水线输出。

bq mk \
  --location=LOCATION \
  --project_id=PROJECT_ID \
  my_bq_output_dataset

创建输入数据集

运行以下命令,创建要将示例银行表复制到其中的数据集。

bq mk \
  --location=LOCATION \
  --project_id=PROJECT_ID \
  my_bq_input_dataset

复制示例数据集

示例银行数据作为 BigQuery 公共数据集提供。此数据集的主要功能包括:

  • 100,000 方
  • 从 2020 年 1 月 1 日到 2023 年 1 月 1 日的核心时间范围,以及额外的 24 个月的回溯期
  • 每月 300 个排除和 20 个正风险案例
  • 具有以下属性的风险案例:
    • 一半的正风险案例都与 AML_PROCESS_START 事件之前的两个月内发生的活动有关
    • 另一半涵盖 AML_PROCESS_START 事件之前的两个月内收款金额最高的各方
    • 随机生成负例
    • 风险用例为相反状态生成 0.1% 的几率(例如,随机为正例的一方,或有结构化活动或收入最高且被报告为负例的一方)
  1. 运行以下命令,将示例银行数据复制到您创建的输入数据集。

    bq mk --transfer_config \
      --project_id="PROJECT_ID" \
      --data_source=cross_region_copy \
      --target_dataset="my_bq_input_dataset" \
      --display_name="Copy the AML sample dataset." \
      --schedule=None \
      --params='{
        "source_project_id":"bigquery-public-data",
        "source_dataset_id":"aml_ai_input_dataset",
        "overwrite_destination_table":"true"
      }'
    
  2. 在 Google Cloud 控制台中打开 BigQuery。

    前往 Google Cloud 控制台

  3. 探索器窗格中查找并展开输入数据集。几分钟后,您应该会在输入数据集中看到表。您还可以通过从 BigQuery 导航菜单中选择数据传输来查看转移状态。AML 架构在 AML 输入数据模型中定义。

授予对 BigQuery 数据集的访问权限

API 会自动在您的项目中创建一个服务帐号。该服务帐号需要能够访问 BigQuery 输入和输出数据集。

  1. 在开发机器上安装 jq。如果您无法在开发机器上安装 jq,可以使用 Cloud Shell 或 BigQuery 文档中提供的其他授予对资源的访问权限的方法。
  2. 运行以下命令以授予对输入数据集及其表的读取权限。
# Request the current access permissions on the BigQuery dataset and store them in a temp file.
bq show --format=prettyjson "PROJECT_ID:my_bq_input_dataset" | jq '.access+=[{"role":"READER","userByEmail":"service-PROJECT_NUMBER@gcp-sa-financialservices.iam.gserviceaccount.com" }]'> /tmp/mydataset.json
# Update the BigQuery dataset access permissions using the temp file.
bq update --source /tmp/mydataset.json "PROJECT_ID:my_bq_input_dataset"

# Grant the API read access to the BigQuery table if the table is provided.
for table in party account_party_link transaction risk_case_event party_supplementary_data
do
   [ -n table ] && bq add-iam-policy-binding \
     --member="serviceAccount:service-PROJECT_NUMBER@gcp-sa-financialservices.iam.gserviceaccount.com" --role="roles/bigquery.dataViewer" \
     PROJECT_ID:my_bq_input_dataset.${table}
done

运行以下命令以授予对输出数据集的写入权限。

# Request the current access permissions on the BigQuery dataset and store them in a temp file.
bq show --format=prettyjson "PROJECT_ID:my_bq_output_dataset" | jq '.access+=[{"role":"roles/bigquery.dataEditor","userByEmail":"service-PROJECT_NUMBER@gcp-sa-financialservices.iam.gserviceaccount.com" }]'> /tmp/mydataset.json
# Update the BigQuery dataset access permissions using the temp file.
bq update --source /tmp/mydataset.json "PROJECT_ID:my_bq_output_dataset"

创建 AML AI 数据集

创建 AML AI 数据集,以指定要使用的输入 BigQuery 数据集表和时间范围。

如需创建数据集,请使用 projects.locations.instances.datasets.create 方法。

请求 JSON 正文:

{
  "tableSpecs": {
    "party": "bq://PROJECT_ID.my_bq_input_dataset.party",
    "account_party_link": "bq://PROJECT_ID.my_bq_input_dataset.account_party_link",
    "transaction": "bq://PROJECT_ID.my_bq_input_dataset.transaction",
    "risk_case_event": "bq://PROJECT_ID.my_bq_input_dataset.risk_case_event",
    "party_supplementary_data": "bq://PROJECT_ID.my_bq_input_dataset.party_supplementary_data"
  },
  "dateRange": {
    "startTime": "2020-01-01T00:00:0.00Z",
    "endTime": "2023-01-01T00:00:0.00Z"
  },
  "timeZone": {
    "id": "UTC"
  }
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
  "tableSpecs": {
    "party": "bq://PROJECT_ID.my_bq_input_dataset.party",
    "account_party_link": "bq://PROJECT_ID.my_bq_input_dataset.account_party_link",
    "transaction": "bq://PROJECT_ID.my_bq_input_dataset.transaction",
    "risk_case_event": "bq://PROJECT_ID.my_bq_input_dataset.risk_case_event",
    "party_supplementary_data": "bq://PROJECT_ID.my_bq_input_dataset.party_supplementary_data"
  },
  "dateRange": {
    "startTime": "2020-01-01T00:00:0.00Z",
    "endTime": "2023-01-01T00:00:0.00Z"
  },
  "timeZone": {
    "id": "UTC"
  }
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets?dataset_id=my-dataset"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
  "tableSpecs": {
    "party": "bq://PROJECT_ID.my_bq_input_dataset.party",
    "account_party_link": "bq://PROJECT_ID.my_bq_input_dataset.account_party_link",
    "transaction": "bq://PROJECT_ID.my_bq_input_dataset.transaction",
    "risk_case_event": "bq://PROJECT_ID.my_bq_input_dataset.risk_case_event",
    "party_supplementary_data": "bq://PROJECT_ID.my_bq_input_dataset.party_supplementary_data"
  },
  "dateRange": {
    "startTime": "2020-01-01T00:00:0.00Z",
    "endTime": "2023-01-01T00:00:0.00Z"
  },
  "timeZone": {
    "id": "UTC"
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets?dataset_id=my-dataset" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的操作 ID 检查操作结果。(您可以对本指南中使用的其余 API 请求执行此操作。)

创建引擎配置

创建 AML AI 引擎配置,以根据给定的引擎版本自动调整超参数。引擎版本会定期发布,并对应于不同的模型逻辑(例如,定位零售业务线与商业业务线)。

如需创建引擎配置,请使用 projects.locations.instances.engineConfigs.create 方法。

请求 JSON 正文:

{
  "engineVersion": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineVersions/aml-commercial.default.v004.000.202312-000",
  "tuning": {
    "primaryDataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2021-07-01T00:00:00Z",
  },
  "performanceTarget": {
    "partyInvestigationsPerPeriodHint": "30"
  }
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
  "engineVersion": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineVersions/aml-commercial.default.v004.000.202312-000",
  "tuning": {
    "primaryDataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2021-07-01T00:00:00Z",
  },
  "performanceTarget": {
    "partyInvestigationsPerPeriodHint": "30"
  }
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs?engine_config_id=my-engine-config"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
  "engineVersion": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineVersions/aml-commercial.default.v004.000.202312-000",
  "tuning": {
    "primaryDataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2021-07-01T00:00:00Z",
  },
  "performanceTarget": {
    "partyInvestigationsPerPeriodHint": "30"
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs?engine_config_id=my-engine-config" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs/my-engine-config",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

创建模型

创建 AML AI 模型以启动 AML 训练流水线。

如需创建模型,请使用 projects.locations.instances.models.create 方法。

请求 JSON 正文:

{
    "engineConfig": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs/my-engine-config",
    "primaryDataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2021-07-01T00:00:00Z"
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
    "engineConfig": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs/my-engine-config",
    "primaryDataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2021-07-01T00:00:00Z"
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models?model_id=my-model"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
    "engineConfig": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs/my-engine-config",
    "primaryDataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2021-07-01T00:00:00Z"
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models?model_id=my-model" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

创建回测结果

回测预测使用基于现有历史数据的训练后模型。针对数据集中的最近三个月创建回测结果;这些月未用于训练。

如需创建回测结果,请使用 projects.locations.instances.backtestResults.create 方法。

请求 JSON 正文:

{
    "model": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "dataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2023-01-01T00:00:00Z",
    "backtestPeriods": 12,
    "performanceTarget": {
      "partyInvestigationsPerPeriodHint": "150"
    }
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
    "model": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "dataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2023-01-01T00:00:00Z",
    "backtestPeriods": 12,
    "performanceTarget": {
      "partyInvestigationsPerPeriodHint": "150"
    }
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults?backtest_result_id=my-backtest-results"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
    "model": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "dataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2023-01-01T00:00:00Z",
    "backtestPeriods": 12,
    "performanceTarget": {
      "partyInvestigationsPerPeriodHint": "150"
    }
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults?backtest_result_id=my-backtest-results" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults/my-backtest-results",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

导出回测结果元数据

如需从回测结果中导出元数据,请使用 projects.locations.instances.backtestResults.exportMetadata 方法。

请求 JSON 正文:

{
  "structuredMetadataDestination": {
    "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_backtest_results_metadata",
    "writeDisposition": "WRITE_TRUNCATE"
  }
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
  "structuredMetadataDestination": {
    "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_backtest_results_metadata",
    "writeDisposition": "WRITE_TRUNCATE"
  }
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults/my-backtest-results:exportMetadata"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
  "structuredMetadataDestination": {
    "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_backtest_results_metadata",
    "writeDisposition": "WRITE_TRUNCATE"
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults/my-backtest-results:exportMetadata" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults/my-backtest-results",
    "verb": "exportMetadata",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}
  1. 在 Google Cloud 控制台中打开 BigQuery。

    前往 Google Cloud 控制台

  2. 探索器窗格中查找并展开输出数据集。

  3. 选择表格,然后点击预览

  4. 找到名为 ObservedRecallValues 的行。

    BigQuery 中观察到的召回率值。

  5. 假设您每月的调查能力为 120。使用 "partyInvestigationsPerPeriod": "120" 查找召回率值对象。对于以下示例值,如果您将调查限制为风险得分大于 0.53 的各方,那么预计每月将调查 120 个新方。在回测阶段(即 2022 年),您将能识别 86% 的先前系统识别的案例(可能还包括旧系统未能识别的其他案例)。

    {
      "recallValues": [
        ...
        {
          "partyInvestigationsPerPeriod": "105",
          "recallValue": 0.8142077,
          "scoreThreshold": 0.6071321
        },
        {
          "partyInvestigationsPerPeriod": "120",
          "recallValue": 0.863388,
          "scoreThreshold": 0.5339603
        },
        {
          "partyInvestigationsPerPeriod": "135",
          "recallValue": 0.89071035,
          "scoreThreshold": 0.4739899
        },
        ...
      ]
    }
    

导入已注册的各方

在创建预测结果之前,您需要导入已注册的方(即数据集中的客户)。

如需导入已注册的各方,请使用 projects.locations.instances.importRegisteredParties 方法。

请求 JSON 正文:

{
  "partyTables": [
     "bq://PROJECT_ID.my_bq_input_dataset.party_registration"
  ],
  "mode": "REPLACE",
  "lineOfBusiness": "COMMERCIAL"
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
  "partyTables": [
     "bq://PROJECT_ID.my_bq_input_dataset.party_registration"
  ],
  "mode": "REPLACE",
  "lineOfBusiness": "COMMERCIAL"
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance:importRegisteredParties"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
  "partyTables": [
     "bq://PROJECT_ID.my_bq_input_dataset.party_registration"
  ],
  "mode": "REPLACE",
  "lineOfBusiness": "COMMERCIAL"
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance:importRegisteredParties" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance",
    "verb": "importRegisteredParties",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

此操作完成后,您应该会看到 10,000 方已注册。

创建预测结果

根据数据集中的最近 12 个月创建预测结果;训练不会使用这些月份。

如需创建预测结果,请使用 projects.locations.instances.predictionResults.create 方法。

请求 JSON 正文:

{
    "model": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "dataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2023-01-01T00:00:00Z",
    "predictionPeriods": "12",
    "outputs": {
      "predictionDestination": {
        "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_prediction_results",
        "writeDisposition": "WRITE_TRUNCATE"
      },
      "explainabilityDestination": {
        "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_prediction_results_explainability",
        "writeDisposition": "WRITE_TRUNCATE"
      }
    }
}

如需发送请求,请选择以下方式之一:

curl

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

cat > request.json << 'EOF'
{
    "model": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "dataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2023-01-01T00:00:00Z",
    "predictionPeriods": "12",
    "outputs": {
      "predictionDestination": {
        "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_prediction_results",
        "writeDisposition": "WRITE_TRUNCATE"
      },
      "explainabilityDestination": {
        "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_prediction_results_explainability",
        "writeDisposition": "WRITE_TRUNCATE"
      }
    }
}
EOF

然后,执行以下命令以发送 REST 请求:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/predictionResults?prediction_result_id=my-prediction-results"

PowerShell

将请求正文保存在名为 request.json 的文件中。在终端中运行以下命令,在当前目录中创建或覆盖此文件:

@'
{
    "model": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "dataset": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "endTime": "2023-01-01T00:00:00Z",
    "predictionPeriods": "12",
    "outputs": {
      "predictionDestination": {
        "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_prediction_results",
        "writeDisposition": "WRITE_TRUNCATE"
      },
      "explainabilityDestination": {
        "tableUri": "bq://PROJECT_ID.my_bq_output_dataset.my_prediction_results_explainability",
        "writeDisposition": "WRITE_TRUNCATE"
      }
    }
}
'@  | Out-File -FilePath request.json -Encoding utf8

然后,执行以下命令以发送 REST 请求:

$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://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/predictionResults?prediction_result_id=my-prediction-results" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/predictionResults/my-prediction-results",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

在 Google Cloud 控制台中分析单个结构化案例

  1. 在 Google Cloud 控制台中打开 BigQuery。确保已选择 SQL 工作区

    前往 Google Cloud 控制台

  2. BigQuery 页面包含三个主要部分:

    • BigQuery 导航菜单
    • 浏览器窗格
    • “详细信息”窗格

    在“详细信息”窗格中,点击编写新查询以打开查询编辑器。

    编写一个新查询。

  3. 将以下 SQL 语句复制到编辑器中,然后点击运行

    SELECT *
    FROM `PROJECT_ID.my_bq_input_dataset.transaction`
    WHERE account_id = '1E60OAUNKP84WDKB' AND DATE_TRUNC(book_time, MONTH) = "2022-08-01"
    ORDER by book_time
    

    此对账单已于 2022 年 8 月检查账号 ID 1E60OAUNKP84WDKB。此帐号已与第三方 ID EGS4NJD38JZ8NTL8 相关联。您可以使用 AccountPartyLink 表来查找指定帐号 ID 对应的参与方 ID。

    交易数据显示了针对单个帐号的一系列圆形交易,这些看起来很可疑。

    某一方的可疑交易数据。

  4. 将以下 SQL 语句复制到编辑器中,然后点击运行

    SELECT *
    FROM `PROJECT_ID.my_bq_input_dataset.risk_case_event`
    WHERE party_id = 'EGS4NJD38JZ8NTL8'
    

    此声明表明存在导致该方退出的风险案例。风险案例在可疑活动两个月后开始。

    单个方的风险案例事件。

  5. 将以下 SQL 语句复制到编辑器中,然后点击运行

    SELECT *
    FROM `PROJECT_ID.my_bq_output_dataset.my_prediction_results`
    WHERE party_id = 'EGS4NJD38JZ8NTL8'
    ORDER BY risk_period_end_time
    

    通过查看预测结果,您可以看到在可疑活动后的几个月内,该方的风险得分从近零(注意指数值)跳到高值。您实际看到的结果可能与显示的结果不同。

    某一方的风险得分增加。

    风险评分并非概率,风险得分应始终相对于其他风险得分进行评估。例如,在其他风险得分较低的情况下,一个看似较小的值可以视为正数。

  6. 将以下 SQL 语句复制到编辑器中,然后点击运行

    SELECT *
    FROM `PROJECT_ID.my_bq_output_dataset.my_prediction_results_explainability`
    WHERE party_id = 'EGS4NJD38JZ8NTL8'
    AND risk_period_end_time = '2022-10-01'
    

    通过检查可解释性结果,您可以看到正确的特征系列得分最高。

    预测结果的可解释性结果。

清理

为避免因本页面中使用的资源导致您的 Google Cloud 账号产生费用,请删除包含这些资源的 Google Cloud 项目。

删除预测结果

如需删除预测结果,请使用 projects.locations.instances.predictionResults.delete 方法。

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/predictionResults/my-prediction-results"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/predictionResults/my-prediction-results" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/predictionResults/my-prediction-results",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

删除回测结果

如需删除回测结果,请使用 projects.locations.instances.backtestResults.delete 方法。

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults/my-backtest-results"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults/my-backtest-results" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/backtestResults/my-backtest-results",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

删除模型

如需删除模型,请使用 projects.locations.instances.models.delete 方法。

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/models/my-model",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

删除引擎配置

如需删除引擎配置,请使用 projects.locations.instances.engineConfigs.delete 方法。

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs/my-engine-config"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs/my-engine-config" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/engineConfigs/my-engine-config",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

删除数据集

如需删除数据集,请使用 projects.locations.instances.datasets.delete 方法。

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance/datasets/my-dataset",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

删除实例

如需删除实例,请使用 projects.locations.instances.delete 方法。

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance"

PowerShell

执行以下命令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://financialservices.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/my-instance" | Select-Object -Expand Content

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.financialservices.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/LOCATION/instances/my-instance",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

删除 BigQuery 数据集

bq rm -r -f -d PROJECT_ID:my_bq_input_dataset
bq rm -r -f -d PROJECT_ID:my_bq_output_dataset

后续步骤