289
Amazon Personalize 开发人员指南

Amazon Personalize - ¼€‘‘Œ‡—

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize开发人员指南

Page 2: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

Amazon Personalize: 开发人员指南Copyright © 2020 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.

Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's,in any manner that is likely to cause confusion among customers, or in any manner that disparages or discreditsAmazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may notbe affiliated with, connected to, or sponsored by Amazon.

Page 3: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

Table of Contents什么是 Amazon Personalize? .............................................................................................................. 1

您是 Amazon Personalize 的新用户吗? ......................................................................................... 1您是经验丰富的 Amazon Personalize 用户吗? ................................................................................ 2

如何使用 ............................................................................................................................................ 3Amazon Personalize 工作流程 ...................................................................................................... 3数据集和数据集组 ....................................................................................................................... 4用户事件 .................................................................................................................................... 4配方和解决方案 .......................................................................................................................... 4指标 .......................................................................................................................................... 4活动 .......................................................................................................................................... 5建议 .......................................................................................................................................... 5

设置 Amazon Personalize .................................................................................................................... 6注册 AWS ................................................................................................................................. 6区域和终端节点 .......................................................................................................................... 6设置权限 .................................................................................................................................... 6

所需权限 ............................................................................................................................ 7创建 IAM 角色 .................................................................................................................... 7

设置 AWS CLI ........................................................................................................................... 9设置 AWS 开发工具包 ................................................................................................................. 9

入门 ................................................................................................................................................ 11先决条件 .................................................................................................................................. 11创建训练数据 ............................................................................................................................ 11入门(控制台) ......................................................................................................................... 12入门 (AWS CLI) ........................................................................................................................ 23入门(适用于 Python 的 AWS 开发工具包) ................................................................................. 30

先决条件 .......................................................................................................................... 31(可选)使用 Jupyter (iPython) 笔记本探索 Amazon Personalize API ........................................ 32

清理资源 .................................................................................................................................. 32准备和导入数据 ................................................................................................................................. 33

数据集和架构 ............................................................................................................................ 33使用 Python 创建架构 ........................................................................................................ 35筛选用户-交互训练数据集中的记录 ....................................................................................... 36

为您的输入数据设置格式 ............................................................................................................ 39分类数据 .......................................................................................................................... 40

上传至 S3 存储桶 ...................................................................................................................... 40导入数据 .................................................................................................................................. 40

使用 Python 导入数据 ........................................................................................................ 40记录事件 .......................................................................................................................................... 43

创建数据集组 ............................................................................................................................ 43获取跟踪 ID .............................................................................................................................. 43事件-交互数据集 ........................................................................................................................ 44PutEvents 操作 ......................................................................................................................... 45事件指标 .................................................................................................................................. 47事件和解决方案 ......................................................................................................................... 47

创建解决方案 .................................................................................................................................... 48使用预定义配方 ......................................................................................................................... 50

预定义配方 ....................................................................................................................... 51HRNN ............................................................................................................................. 52HRNN 元数据 ................................................................................................................... 54HRNN-Coldstart ................................................................................................................ 57热门程度-计数 ................................................................................................................... 60个性化-排名 ...................................................................................................................... 61SIMS ............................................................................................................................... 63

覆盖默认配方参数 ...................................................................................................................... 66

iii

Page 4: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

超级参数和 HPO ............................................................................................................... 67评估解决方案版本 .............................................................................................................................. 69

指标 ........................................................................................................................................ 69示例 ........................................................................................................................................ 70更多信息 .................................................................................................................................. 71

创建活动 .......................................................................................................................................... 72获得推荐 .......................................................................................................................................... 73

推荐评分的工作原理 .................................................................................................................. 73获取实时推荐 ............................................................................................................................ 73

GetRecommendations ........................................................................................................ 73获取个性化排名 ................................................................................................................. 74

获取批量推荐 ............................................................................................................................ 75获取批处理建议(Amazon Personalize 控制台) .................................................................... 77获取批处理建议 (AWS CLI) ................................................................................................. 78获取批处理建议(AWS Python 开发工具包) ........................................................................ 79

安全性 ............................................................................................................................................. 80数据保护 .................................................................................................................................. 80

静态加密 .......................................................................................................................... 81传输中加密 ....................................................................................................................... 81密钥管理 .......................................................................................................................... 81

Identity and Access Management ................................................................................................ 81受众 ................................................................................................................................ 81使用身份进行身份验证 ....................................................................................................... 82使用策略管理访问 .............................................................................................................. 83Amazon Personalize 如何与 IAM 协同工作 ............................................................................ 84基于身份的策略示例 .......................................................................................................... 86故障排除 .......................................................................................................................... 89

日志记录和监控 ......................................................................................................................... 90监控 ................................................................................................................................ 90Amazon Personalize 的 CloudWatch 指标 ............................................................................. 93使用 AWS CloudTrail 记录 Amazon Personalize API 调用 ....................................................... 95

合规性验证 ............................................................................................................................... 96恢复功能 .................................................................................................................................. 97基础设施安全 ............................................................................................................................ 97

限制 ................................................................................................................................................ 98支持的 AWS 区域 ..................................................................................................................... 98合规性 ..................................................................................................................................... 98服务限制 .................................................................................................................................. 98

API 参考 ........................................................................................................................................ 100Actions .................................................................................................................................. 100

Amazon Personalize ........................................................................................................ 101Amazon Personalize Events ............................................................................................. 199Amazon Personalize Runtime ........................................................................................... 201

Data Types ............................................................................................................................ 206Amazon Personalize ........................................................................................................ 207Amazon Personalize Events ............................................................................................. 277Amazon Personalize Runtime ........................................................................................... 279

Common Errors ...................................................................................................................... 280Common Parameters ............................................................................................................... 282

文档历史记录 .................................................................................................................................. 284AWS 词汇表 ................................................................................................................................... 285

iv

Page 5: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南您是 Amazon Personalize 的新用户吗?

什么是 Amazon Personalize?Amazon Personalize 是一项机器学习服务,使开发人员能够轻松地将个性化推荐添加到使用其应用程序的客户。它反映了 Amazon 在构建个性化系统方面丰富的经验。

您可以在各种场景中使用 Amazon Personalize,例如,根据用户的偏好和行为向用户提供推荐、对结果进行个性化重新排名以及为电子邮件和通知个性化内容。

Amazon Personalize 不需要大量机器学习经验。您可以使用 AWS 控制台或使用 AWS 开发工具包以编程方式来构建、训练和部署解决方案版本(经过训练的 Amazon Personalize 推荐模型)。作为开发人员,您只需执行以下操作:

• 设置输入数据的格式并将数据上传到 Amazon S3 存储桶,或发送实时事件数据。• 选择要对数据使用的训练配方(算法)。• 使用配方训练解决方案版本。• 部署解决方案版本。

Amazon Personalize 可以捕获用户的实时事件以实现实时个性化。Amazon Personalize 可以根据用户当前的会话和活动,将实时用户活动数据与现有用户配置文件和项目信息混合,以推荐最相关的项目。您也可以使用 Amazon Personalize 收集新属性的数据(例如,一个全新的网站),在收集到足够的数据后,AmazonPersonalize 就可以开始进行推荐。

要向您的用户进行推荐,请调用推荐 API 之一,然后为用户创建个性化体验。

随着新用户活动数据的收集,Amazon Personalize 可以随着时间的推移改进其建议。例如,用户执行的新电影租赁事件可以产生更好的电影推荐。

Amazon Personalize 可以根据用户的浏览上下文提供相应的建议。例如,当某个用户在移动设备上浏览时,以及当同一个用户在台式机上浏览时,Amazon Personalize 可以提供不同的建议。

借助 Amazon Personalize,您可以为不同使用案例训练解决方案。例如,用户个性化、与某个项目相关的项目和项目的重新排名。您可以根据使用案例选择一种配方并提供输入数据。配方会对数据进行特征化,并应用学习算法的选择以及默认超参数和超参数优化作业配置。

Amazon Personalize 中的配方可让您创建自定义个性化模型,而无需机器学习专业知识。您可以选择要用于训练解决方案版本的配方,或者让 Amazon Personalize 决定要用于您的数据的最佳配方。为了帮助您决定要使用的配方,Amazon Personalize 提供了有关训练后解决方案版本的性能的大量指标。

您是 Amazon Personalize 的新用户吗?如果您是首次接触 Amazon Personalize 的用户,我们建议您按顺序阅读以下内容:

1. 如何使用 (p. 3) – 本部分介绍了您可以用来打造端到端体验的各种 Amazon Personalize 组件。2. 入门 (p. 11) – 在本部分中,您将设置您的账户并测试 Amazon Personalize 控制台和 API。3. 准备和导入数据 (p. 33) – 本部分介绍如何准备训练数据并将该数据导入 Amazon Personalize 中。4. 记录事件 (p. 43) – 本节提供有关通过记录用户事件来改进用户推荐的信息。5. 创建解决方案 (p. 48) – 本节提供有关通过训练模型来创建解决方案版本的信息。6. 创建活动 (p. 72) – 本节提供有关将解决方案版本部署为市场活动的信息。7. 获得推荐 (p. 73) – 本部分介绍如何从活动中获取建议。

1

Page 6: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南您是经验丰富的 Amazon Personalize 用户吗?

您是经验丰富的 Amazon Personalize 用户吗?如果您是经验丰富的 Amazon Personalize 用户,您可以在 amazon-personalize-samples GitHub 存储库中找到进阶教程和代码示例。

2

Page 7: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize 工作流程

如何使用为了进行推荐,Amazon Personalize 使用了借助您的数据训练过的机器学习模型。用于训练模型的数据存储在数据集组的相关数据集中。每个模型通过使用包含针对特定使用案例的算法的配方进行训练。在 AmazonPersonalize 中,经过训练的模型称为解决方案版本。可以部署解决方案版本来用于市场活动。您的应用程序的用户可以通过市场活动获得推荐。例如,活动可以在网站或应用程序上显示电影推荐,其中显示的标题基于属于数据集一部分的查看习惯。

数据集可以随着时间的推移而增大,您的模型可以基于新数据重新训练。数据可能来自新的元数据以及对实时用户事件数据的使用。在之前的电影推荐示例中,您可以在新电影发行时添加新电影,也可以添加由登录用户选择的电影。

Amazon Personalize 具有您可以用来创建、管理和部署解决方案版本的 AWS 控制台。此外,您还可以使用AWS Command Line Interface (AWS CLI) 或其中一个 Amazon Personalize 开发工具包。

Amazon Personalize 包含三个相关组件:

• Amazon Personalize – 用于创建、管理和部署解决方案版本。• Amazon Personalize 事件 – 用于记录用户事件以将其添加至您的训练数据。有关更多信息,请参阅 记录

事件 (p. 43)。• Amazon Personalize 运行时 – 用于从市场活动(部署的解决方案版本)获取推荐。有关更多信息,请参阅

获得推荐 (p. 73)。

主题• Amazon Personalize 工作流程 (p. 3)• 数据集和数据集组 (p. 4)• 用户事件 (p. 4)• 配方和解决方案 (p. 4)• 指标 (p. 4)• 活动 (p. 5)• 建议 (p. 5)

Amazon Personalize 工作流程用于训练、部署和从活动获取推荐的工作流程为:

1. 创建相关数据集和数据集组。2. 获取训练数据。

• 将历史数据导入到数据集组。• 将用户事件记录到数据集组。

3. 使用配方创建解决方案版本(已训练模型)。4. 使用指标评估解决方案版本。5. 创建市场活动(部署解决方案版本)。6. 为用户提供推荐。

以下部分简要概述了上述工作流程。每个部分都包含一个指向主要主题的链接,该主题深入介绍了相应步骤并提供了一个 Python 示例。

3

Page 8: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南数据集和数据集组

入门 (p. 11)指南提供了使用 Amazon Personalize 控制台、AWS CLI 和 Jupyter (iPython) 笔记本的分步过程。

数据集和数据集组Amazon Personalize 需要存储在 Amazon Personalize 数据集中的数据来训练模型。

有两种方法可以提供训练数据。可以从 Amazon S3 存储桶导入历史数据,也可以在创建事件数据时记录它。

数据集组包含相关数据集。由客户创建三种类型的历史数据集(用户、项目和交互),由 AmazonPersonalize 为实时事件交互创建一种类型。数据集组只能包含每种数据集中的一个。

您可以创建不同的数据集组来满足不同的用途。例如,您可能有一个提供购买鞋子的推荐的应用程序,还有一个提供欧洲旅游地点的推荐的应用程序。在 Amazon Personalize 中,每个应用程序都有自己的数据集组。

历史数据必须以 CSV 文件格式提供。每种数据集类型均具有指定 CSV 文件内容的唯一架构。

存在训练模型所需的最低数据量 (p. 98)。使用现有数据,您可以立即开始训练模型。如果您依赖在创建时记录的数据,并且没有历史数据,则可能需要一些时间才能开始训练。

有关更多信息,请参阅准备和导入数据 (p. 33)。

用户事件Amazon Personalize 可以使用实时用户事件数据来独自用于或与历史数据结合用于模型训练。

有关更多信息,请参阅 记录事件 (p. 43)。

配方和解决方案在交互数据集(历史和实时事件)中提供了足够的数据后,可以将这些数据用于训练模型。经过训练的模型称为解决方案版本。模型是使用配方经过训练的。Amazon Personalize 中提供的配方包括算法和数据处理步骤,这些步骤根据您的输入数据为特定类型的推荐优化解决方案。

Amazon Personalize 支持许多预定义配方。Amazon Personalize 可以根据其对训练数据的分析自动选择最合适的配方。或者,您也可以选择要用于训练模型的配方。每个配方都有自己的使用案例,您应选择最符合您需求的配方。

每次训练模型时,都会为它分配一个新解决方案版本。使用解决方案版本 ARN 可确定要为您的活动使用的解决方案版本。

有关更多信息,请参阅创建解决方案 (p. 48)。

指标创建完解决方案版本后,您将评估在训练期间创建的指标。这些指标可指示解决方案版本的性能。控制台将显示指标,并在必要时允许您创建新的解决方案版本。此外,也可以调用 GetSolutionMetrics (p. 169)API。通常情况下,使用多个配方训练模型,并使用生成的指标显示最佳性能的配方。基于所选配方创建解决方案版本后,该解决方案版本可以部署为市场活动。

4

Page 9: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南活动

有关更多信息,请参阅 评估解决方案版本 (p. 69)。

活动已部署的解决方案版本称为市场活动。活动允许 Amazon Personalize 对您的用户进行推荐。要部署解决方案版本,您应在控制台中或通过调用 CreateCampaign (p. 106) API 创建一个市场活动。您选择要使用的解决方案版本。

有关更多信息,请参阅 创建活动 (p. 72)。

建议在您创建活动后,将能够获得两种不同类型的推荐,具体取决于用于训练模型的配方类型。

对于用户个性化和相关项目配方,GetRecommendations (p. 204) API 会返回推荐项目的列表。例如,可以为登录到网站的用户推荐电影。

对于个性化排名配方,GetPersonalizedRanking (p. 202) API 会根据指定的查询对推荐项目的列表进行重新排名。

您还可以使用批处理工作流 (p. 75),针对不需要实时更新的大型数据集获取建议。

有关更多信息,请参阅 获得推荐 (p. 73)。

5

Page 10: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南注册 AWS

设置 Amazon Personalize在使用 Amazon Personalize 之前,您必须拥有 Amazon Web Services (AWS) 账户。在您拥有 AWS 账户后,可以通过 Amazon Personalize 控制台、AWS Command Line Interface (AWS CLI) 或 AWS 开发工具包访问 Amazon Personalize。

本指南包括使用 AWS Amplify 的 AWS CLI、Python 和 JavaScript 的示例。

主题• 注册 AWS (p. 6)• 区域和终端节点 (p. 6)• 设置权限 (p. 6)• 设置 AWS CLI (p. 9)• 设置 AWS 开发工具包 (p. 9)

注册 AWS当您注册 Amazon Web Services (AWS) 时,您的账户会自动注册 AWS 中的所有服务,包括 AmazonPersonalize。您只需为使用的服务付费。

如果您已有一个 AWS 账户,请跳到下一个任务。如果您还没有 AWS 账户,请使用以下步骤创建。

注册 AWS

1. 打开 https://aws.amazon.com,然后选择 Create an AWS Account (创建 AWS 账户)。2. 按照屏幕上的说明完成账户创建。请记下您的 12 位 AWS 账号。作为注册流程的一部分,您会收到一个

电话,需要您使用电话键盘输入一个 PIN 码。3. 创建 AWS Identity and Access Management (IAM) 管理员用户。有关说明,请参阅 AWS Identity and

Access Management 用户指南 中的创建您的第一个 IAM 用户和组。

具备管理员权限的 IAM 用户可以无限制地访问您账户中的 AWS 服务。有关限制对 Amazon Personalize操作的访问的信息,请参阅 Amazon Personalize 基于身份的策略 (p. )

4. 创建 IAM 用户以使用 Amazon Personalize。账户需要特定权限。有关更多信息,请参阅 设置权限 (p. 6)。

区域和终端节点终端节点是作为 Web 服务入口点的 URL。每个终端节点都与特定的 AWS 区域关联。请注意 AmazonPersonalize 控制台、AWS CLI 和 Amazon Personalize 开发工具包的默认区域,因为给定市场活动(数据集、解决方案、市场活动、事件跟踪器)的所有 Amazon Personalize 组件都必须在同一区域中创建。有关Amazon Personalize 支持的区域和终端节点,请参阅区域和终端节点。

设置权限要使用 Amazon Personalize,您必须设置权限,以便允许访问 Amazon Personalize 控制台和 API 操作。您还必须允许 Amazon Personalize 代表您执行任务和访问您拥有的资源。

我们建议创建具有局限于 Amazon Personalize 操作的访问权限的用户。您可以根据需要添加其他权限。有关更多信息,请参阅 Amazon Personalize 基于身份的策略 (p. )。

6

Page 11: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南所需权限

主题• 所需权限 (p. 7)• 创建 IAM 角色 (p. 7)

所需权限以下策略提供了使用 Amazon Personalize 所需的权限。

AmazonPersonalizeFullAccess 策略

您可以执行以下操作:• 访问所有 Amazon Personalize 资源• 发布和列出 Amazon CloudWatch 上的指标• 列出、读取、写入和删除 Amazon S3 存储桶中将 Personalize 或 personalize 包含在存储桶名

称中的所有对象• 将角色传递到 Amazon Personalize

有关创建将这些参数传递到 Amazon Personalize 的 IAM 角色的分步过程,请参阅创建 IAM 角色 (p. 7)。

Amazon S3 存储桶策略

允许 Amazon Personalize 访问包含您的训练数据的 S3 存储桶。有关更多信息,请参阅 上传至 S3 存储桶 (p. 40)。

CloudWatchFullAccess 策略(可选)

AmazonPersonalizeFullAccess 策略提供在 CloudWatch 中发布和列出 Amazon Personalize 指标的权限。CloudWatchFullAccess 策略添加其他权限,例如查看指标、显示指标统计数据和设置基于指标的警报。有关更多信息,请参阅 监控 Amazon Personalize (p. 90)。

Note

由于 Amazon Personalize 不与 AWS VPC 通信,因此 Amazon Personalize 将无法与只允许 VPC访问的 Amazon S3 存储桶进行交互。

创建 IAM 角色在以下过程中,您将创建一个 IAM 角色,该角色允许 Amazon Personalize 访问您的资源和代表您执行任务。

用户需要权限来创建 IAM 角色。要授予用户权限,请参阅创建向 AWS 服务委派权限的角色。

1. 登录 IAM 控制台 (https://console.aws.amazon.com/iam)。2. 在导航窗格中,选择 Roles。3. 选择 Create role (创建角色)。4. 对于 Select type of trusted entity (选择受信任实体的类型),选择 AWS service (AWS 服务)。5. 对于 Choose the service that will use this role (选择将使用此角色的服务),选择 Amazon Personalize。

如果您没有看到列出的 Amazon Personalize,请选择 EC2 并将 EC2 作为您的使用案例。6. 选择 Next: Permissions (下一步: 权限)。7. 对于 Attach permissions policies (附加权限策略),选择 AmazonPersonalizeFullAccess。

a. 要显示列表中的策略,请在 Filter policies (筛选策略) 查询筛选器中键入部分策略名称。b. 选中 AmazonPersonalizeFullAccess 旁边的复选框。

7

Page 12: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南创建 IAM 角色

c. (可选)为 CloudWatchFullAccess 重复步骤 a. 和 b.。8. 选择下一步:标签。您不需要添加任何标签。选择下一步:审核。9. 在 Review (审核) 部分中,对于 Role name (角色名称),输入角色的名称(例

如,PersonalizeRole)。在角色描述中更新角色描述,然后选择创建角色。10. 选择新角色以打开该角色的摘要页面。11. 复制 Role ARN (角色 ARN) 值,然后保存。您需要它才能将数据集导入 Amazon Personalize 中。12. 如果您没有选择 Amazon Personalize 作为将使用此角色的服务,请执行以下额外步骤。

a. 选择 Trust Relationships (信任关系)。b. 选择 Edit trust relationship (编辑信任关系) 并更新信任策略以匹配以下项。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "personalize.amazonaws.com" }, "Action": "sts:AssumeRole" } ]}

c. 选择 Update Trust Policy。13. 在导航窗格中选择 Policies (策略),然后选择 Create policy (创建策略)。14. 选择“JSON”选项卡,然后更新策略,如下所示。

{ "Version": "2012-10-17", "Id": "PersonalizeS3BucketAccessPolicy", "Statement": [ { "Sid": "PersonalizeS3BucketAccessPolicy", "Effect": "Allow", "Action": [ "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::bucket-name", "arn:aws:s3:::bucket-name/*" ] } ]}

15. 选择查看策略。16. 对于 Name (名称),输入 PersonalizeS3BucketAccessPolicy。17. (可选)对于 Description (描述),输入描述此策略的简短句子,例如,“Allow Amazon Personalize

to access its S3 bucket (允许 Amazon Personalize 访问其 S3 存储桶)”。18. 选择 Create policy。19. 在导航窗格中选择 Roles (角色),然后选择新角色。20. 对于 Permissions (权限),选择 PersonalizeS3BucketAccessPolicy。

a. 要显示列表中的策略,请在 Filter policies (筛选策略) 筛选框中键入部分策略名称。b. 选中 PersonalizeS3BucketAccessPolicy 旁边的复选框。

8

Page 13: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南设置 AWS CLI

c. 选择 Attach policy。

您的角色现已就绪,可用于 Amazon Personalize。记录角色 ARN。您需要它来导入作业。

设置 AWS CLIAWS 命令行界面 (AWS CLI) 是一种用于管理 AWS 服务(包括 Amazon Personalize)的统一开发工人员工具。我们建议您安装它。

1. 要安装 AWS CLI,请遵循 AWS 命令行界面用户指南 中的安装 AWS 命令行界面中的说明。2. 要配置 AWS CLI 并设置配置文件以调用 AWS CLI,请遵循 AWS 命令行界面用户指南 中的配置 AWS

CLI 中的说明。3. 要确认已正确配置 AWS CLI 配置文件,请运行以下命令。

aws configure --profile default

如果您的配置文件已正确配置,您将看到类似于以下内容的输出。

AWS Access Key ID [****************52FQ]: AWS Secret Access Key [****************xgyZ]: Default region name [us-west-2]: Default output format [json]:

4. 要验证 AWS CLI 是否已配置为与 Amazon Personalize 结合使用,请运行以下命令。

aws personalize help

aws personalize-runtime help

aws personalize-events help

如果已正确配置 AWS CLI,您将看到 Amazon Personalize、Amazon Personalize 运行时和 AmazonPersonalize 事件支持的 AWS CLI 命令的列表。

如果您设置 AWS CLI,但它无法识别 Amazon Personalize 的命令,请更新 AWS CLI。要更新 AWSCLI,请运行以下命令。

pip3 install awscli --upgrade --user

有关更多信息,请参阅使用 pip 安装 AWS CLI。

设置 AWS 开发工具包下载并安装要使用的 AWS 开发工具包。本指南提供了使用 AWS Amplify 库的 Python 和 JavaScript 示例。有关其他 AWS 开发工具包的信息,请参阅用于 Amazon Web Services 的工具。

9

Page 14: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南设置 AWS 开发工具包

• 适用于 Python 的 AWS 开发工具包 (Boto3)

要确认已正确配置 Python 环境以用于 Amazon Personalize,请参阅入门(适用于 Python 的 AWS 开发工具包) (p. 30)。

• AWS Amplify

10

Page 15: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南先决条件

入门本入门指南向您展示如何基于包含 600 个用户对 9700 部电影的 100000 个电影评级的历史数据,为用户创建返回电影推荐的市场活动。

简化本指南:

• 我们依赖用户看过电影这个事实而非用户对电影的评级。这简化了训练数据的准备。• 我们不记录实时用户交互事件。有关捕获用户事件的信息,请参阅记录事件 (p. 43)。

要开始,请下载并准备训练数据。接下来,请创建一个允许 Amazon Personalize 代表您访问数据的AWS Identity and Access Management (IAM) 角色。在创建训练数据和角色之后,请继续入门(控制台) (p. 12)或入门 (AWS CLI) (p. 23)。

完成入门练习后,您可能希望删除所创建的资源。有关更多信息,请参阅 清理资源 (p. 32)。

主题• 先决条件 (p. 11)• 创建训练数据 (p. 11)• 入门(控制台) (p. 12)• 入门 (AWS CLI) (p. 23)• 入门(适用于 Python 的 AWS 开发工具包) (p. 30)• 清理资源 (p. 32)

先决条件以下步骤是入门练习的先决条件。

• 创建 AWS 账户和 AWS Identity and Access Management 用户,如注册 AWS (p. 6) 中所述。• 确保您使用的 IAM 用户具有所需权限 (p. 7)。• 创建一个 AWS Identity and Access Management (IAM) 服务角色,如创建 IAM 角色 (p. 7)中所述。在上传

电影训练数据时使用该角色 ARN。• 准备您的训练数据并将该数据上传到 Amazon S3 存储桶,如创建训练数据 (p. 11)中所述。在上传电影

训练数据时使用该 Amazon S3 存储桶的名称。

创建训练数据要创建训练数据,请下载、修改电影评级数据并将此数据保存到 Amazon Simple Storage Service (AmazonS3) 存储桶。然后,向 Amazon Personalize 提供从存储桶进行读取的权限。

1. 从 MovieLens(位于推荐用于教育和发展下)下载电影评级 zip 文件 ml-latest-small.zip。解压缩该文件。用户交互数据位于名为 ratings.csv 的文件中。

2. 打开 ratings.csv 文件。

a. 删除评级 列。

11

Page 16: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

b. 使用以下内容替换标题行:

USER_ID,ITEM_ID,TIMESTAMP

这些标题必须与所示内容完全相同,Amazon Personalize 才能识别数据。

保存 ratings.csv 文件。3. 将 ratings.csv 上传到您的 Amazon S3 存储桶。有关更多信息,请参阅 Amazon Simple Storage

Service 控制台用户指南中的使用拖放操作上传文件和文件夹。4. 向 Amazon Personalize 授予读取存储桶中的数据的权限。有关更多信息,请参阅 上传至 S3 存储

桶 (p. 40)。

入门(控制台)在本练习中,您将使用 Amazon Personalize 控制台创建一个为给定用户返回电影推荐的活动。

在开始本练习之前,请查看入门先决条件 (p. 11)。

在您完成本练习后,请参阅清理资源 (p. 32)。

步骤 1:导入训练数据在此过程中,您首先创建一个数据集组。接下来,您在数据集组中创建一个 Amazon Personalize 用户-项目交互数据集并创建一个架构来匹配您的训练数据。接下来,您将训练数据导入到该数据集。

导入训练数据

1. 在 https://console.aws.amazon.com/personalize/ 上打开 Amazon Personalize 控制台并登录到您的账户。

2. 选择 Create dataset group (创建数据集组)。3. 如果这是您第一次使用 Amazon Personalize,请在 Create dataset group (创建数据集组) 页面上的 New

dataset group (新建数据集组) 中,选择开始使用。4. 在 Dataset group details (数据集组详细信息) 中,对于 Dataset group name (数据集组名称),为您的数

据集组指定一个名称。您的屏幕应类似于以下内容:

12

Page 17: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

5. 选择 Next。6. 在 Create user-item interaction data (创建用户-项目交互数据) 页面上,在 Dataset details (数据集详细

信息) 中,对于 Dataset name (数据集名称),指定数据集的名称。7. 在 Schema details (架构详细信息) 中,对于 Schema selection (架构选择),选择 Create new schema

(创建新架构)。将在 Schema definition (架构定义) 字段中显示最小的 Interactions 架构。此架构与您之前添加到 ratings.csv 文件的标题匹配。

8. 对于 New schema name (新架构名称),为新架构指定一个名称。

您的屏幕应类似于以下内容:

13

Page 18: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

14

Page 19: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

9. 选择 Next。10. 在 Import user-item interaction data (导入用户-项目交互数据) 页下,在 Dataset import job details (数据

集导入作业详细信息) 中,对于 Dataset import job name (数据集导入作业名称),为导入作业指定一个名称。

11. 对于 IAM service role (IAM 服务角色),请保留默认选择 Enter a custom IAM role ARN (输入自定义 IAM角色 ARN)。

12. 对于 Custom IAM role ARN (自定义 IAM 角色 ARN),指定您在创建 IAM 角色 (p. 7)中创建的角色。13. 在名为 Additional S3 bucket policy required (需要其他 S3 存储桶策略) 的信息对话框中,按照说

明 (p. 40)添加所需的 Amazon S3 存储桶策略。14. 对于 Data location (数据位置),指定 Amazon Simple Storage Service (S3) 中存储电影数据文件的位

置。使用下面的语法:

s3://<name of your S3 bucket>/<folder path>/<CSV filename>

您的屏幕应类似于以下内容:

15

Page 20: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

15. 选择 Finish。数据导入作业开始,并显示 Dashboard Overview (控制面板概览) 页。16. 最初,在 Upload datasets (上传数据集) 中,User-item interaction data (用户-项目交互数据) 状态为

Create pending (创建待处理)(然后是 Create in progress (创建正在进行中)),且 Create solutions -Start (创建解决方案 - 开始) 按钮被禁用。

Note

导入数据所需的时间取决于数据集的大小。

在数据导入任务完成后,User-item interaction data (用户-项目交互数据) 状态更改为 Active (活动),Create solutions - Start (创建解决方案 - 开始) 按钮被启用。您的屏幕应类似于以下内容:

16

Page 21: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

17. 导入作业完成后,选择 Create solutions - Start (创建解决方案 - 开始) 按钮。此时将显示 Create solution(创建解决方案) 页面。

步骤 2:创建解决方案在此过程中,您使用在上一步中导入的数据集来训练模型。经过训练的模型称为解决方案版本。

创建解决方案

1. 如果 Create solution (创建解决方案) 页面尚未显示,在导航窗格中,在您创建的数据集组下,选择Create solutions - Start (创建解决方案 - 开始) 按钮。

2. 在 Solution configuration (解决方案配置) 中,对于 Solution name (解决方案名称),为解决方案指定一个名称。

3. 对于 Recipe selection (配方选择),选择 Automatic (AutoML) (自动 (AutoML))。保持默认的配方列表。4. 您的屏幕应类似于以下内容:

17

Page 22: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

5. (可选)在 Perform HPO (执行 HPO) 中,要允许 Amazon Personalize 查找配方的最佳超参数,请选择 true。否则,选择 false。

6. 选择 Next。

您的屏幕应类似于以下内容:

18

Page 23: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

7. 不需要修改 Solution config (解决方案配置),因此选择 Finish (完成)。模型训练开始,并显示Dashboard Overview (控制面板概览) 页。

8. 最初,在 Create solutions (创建解决方案) 中,Solution creation (解决方案创建) 状态为 Create pending(创建待处理)(然后是 Create in progress (创建正在进行)),Launch campaigns - Start (启动活动 - 开始) 按钮被禁用,一个横幅显示在控制台的顶部,用来展示进度。

在训练完成后,Dashboard Overview (控制面板概述) 页面被刷新,您的屏幕应该类似于以下内容。

Note

训练模型所需的时间取决于数据集的大小和所选配方。

19

Page 24: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

9. 训练完成后,选择 Create new campaign (创建新活动)。

步骤 3:创建活动在本过程中,您通过部署您在上一步中创建的解决方案版本创建一个活动。

创建活动

1. 如果 Create new campaign (创建新活动) 页尚未显示,则在导航窗格中,在您创建的数据集组中,选择Dashboard (控制面板),然后选择 Create new campaign (创建新活动)。

2. 在 Campaign details (活动详细信息) 中,对于 Campaign name (活动名称),为活动指定一个名称。3. 对于 Solution (解决方案),选择您在上一步中创建的解决方案版本。4. 对于 Minimum provisioned transactions per second (每秒预配置的最小交易数),保留默认值 1。

您的屏幕应类似于以下内容:

20

Page 25: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

5. 选择 Create campaign (创建活动)。随后开始创建活动,Campaign (活动) 页面出现并显示 Campaigninference (活动推理) 部分。

您的屏幕应类似于以下内容:

Note

创建活动需要一些时间。

创建完活动后,页面将更新以显示 Test campaign results (测试活动结果) 部分。您的屏幕应类似于以下内容:

21

Page 26: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(控制台)

步骤 4:获得推荐在此过程中,使用您在前一个步骤中创建的活动来获得推荐。

获得推荐

1. 在 Test campaign results (测试活动结果) 中,对于 User ID (用户 ID),指定评级 数据集中的值,例如,83。

2. 选择 Get recommendations (获得推荐)。Recommended item ID (推荐项目 ID) 列表将显示推荐项目ID。

您的屏幕应类似于以下内容:

22

Page 27: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门 (AWS CLI)

入门 (AWS CLI)在本练习中,您将使用 AWS Command Line Interface (AWS CLI) 探索 Amazon Personalize。您创建一个活动,该活动返回给定用户 ID 的电影推荐。

23

Page 28: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门 (AWS CLI)

在开始本练习之前,请先执行以下操作:

• 查看入门先决条件 (p. 11)。• 设置 AWS CLI,如设置 AWS CLI (p. 9)中所述。

在您完成本练习后,请参阅 清理资源 (p. 32)。

Note

本练习中的 CLI 命令在 Linux 上进行了测试。有关在 Windows 上使用 CLI 命令的信息,请参阅AWS 命令行界面用户指南 中的为 AWS 命令行界面指定参数值。

步骤 1:导入训练数据按照步骤操作以创建一个数据集组,向此组添加数据集,然后使用电影评级数据填充此数据集。

1. 通过运行以下命令来创建数据集组。您可以通过传递 AWS Key Management Service 密钥 ARN 和对该密钥具有访问权限的 IAM 角色的 ARN 作为输入参数来加密数据集组。有关该 API 的更多信息,请参阅CreateDatasetGroup (p. 112)。

aws personalize create-dataset-group --name MovieRatingDatasetGroup --kms-key-arn arn:aws:kms:us-west-2:01234567890:key/1682a1e7-a94d-4d92-bbdf-837d3b62315e --role-arn arn:aws:iam::01234567890:KMS-key-access

这将显示数据集组 ARN,例如:

{ "datasetGroupArn": "arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieRatingDatasetGroup"}

使用 describe-dataset-group 命令显示您创建的数据集组,并指定返回的数据集组 ARN。

aws personalize describe-dataset-group \--dataset-group-arn arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieRatingDatasetGroup

这将显示此数据集组及其属性,例如:

{ "datasetGroup": { "name": "MovieRatingDatasetGroup", "datasetGroupArn": "arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieRatingDatasetGroup", "status": "ACTIVE", "creationDateTime": 1542392161.262, "lastUpdatedDateTime": 1542396513.377 }}

Note

在数据集组中创建数据集之前,等待该组的 status 显示为“ACTIVE”。此操作通常很快。

如果您不记得数据集组 ARN,则使用 list-dataset-groups 命令显示您创建的所有数据集组及其ARN。

24

Page 29: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门 (AWS CLI)

aws personalize list-dataset-groups

Note

describe-object 和 list-objects 命令适用于大多数 Amazon Personalize 对象。这些命令没有在本练习的其余部分中显示,但它们是可用的。

2. 通过将以下代码保存到名为 MovieRatingSchema.json 的文件来创建一个 JSON 格式的架构文件。此架构与您之前添加到 ratings.csv 的标题匹配。架构名称为 Interactions,它与 AmazonPersonalize 识别的三种类型的数据集之一匹配。有关更多信息,请参阅 数据集和数据集组 (p. 4)。

{ "type": "record", "name": "Interactions", "namespace": "com.amazonaws.personalize.schema", "fields": [ { "name": "USER_ID", "type": "string" }, { "name": "ITEM_ID", "type": "string" }, { "name": "TIMESTAMP", "type": "long" } ], "version": "1.0"}

3. 通过运行以下命令创建架构。指定您在上一个步骤中保存的文件。此示例将该文件显示为属于当前文件夹。有关 API 的更多信息,请参阅CreateSchema (p. 121)。

aws personalize create-schema \ --name MovieRatingSchema \ --schema file://MovieRatingSchema.json

这将显示架构 Amazon 资源名称 (ARN),例如:

{ "schemaArn": "arn:aws:personalize:us-west-2:acct-id:schema/MovieRatingSchema"}

4. 通过运行以下命令来创建一个空数据集。提供之前的步骤中返回的数据集组 ARN 和架构ARN。dataset-type 必须与上一个步骤中的架构 name 匹配。有关 API 的更多信息,请参阅CreateDataset (p. 109)。

aws personalize create-dataset \ --name MovieRatingDataset \ --dataset-group-arn arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieRatingDatasetGroup \ --dataset-type Interactions \ --schema-arn arn:aws:personalize:us-west-2:acct-id:schema/MovieRatingSchema

这将显示数据集 ARN,例如:

25

Page 30: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门 (AWS CLI)

{ "datasetArn": "arn:aws:personalize:us-west-2:acct-id:dataset/MovieRatingDatasetGroup/INTERACTIONS"}

5. 将训练数据添加到数据集。

a. 通过运行以下命令来创建数据集导入作业。提供之前的步骤中返回的数据集 ARN 和 Amazon S3 存储桶名称。提供您在创建 IAM 角色 (p. 7)中创建的 AWS Identity and Access Management (IAM) 角色 ARN。有关 API 的更多信息,请参阅CreateDatasetImportJob (p. 115)。

aws personalize create-dataset-import-job \ --job-name MovieRatingImportJob \ --dataset-arn arn:aws:personalize:us-west-2:acct-id:dataset/MovieRatingDatasetGroup/INTERACTIONS \ --data-source dataLocation=s3://bucketname/ratings.csv \ --role-arn roleArn

这将显示数据集导入作业 ARN,例如:

{ "datasetImportJobArn": "arn:aws:personalize:us-west-2:acct-id:dataset-import-job/MovieRatingImportJob"}

b. 通过使用 describe-dataset-import-job 命令来检查状态。提供上一个步骤中返回的数据集导入作业 ARN。有关 API 的更多信息,请参阅DescribeDatasetImportJob (p. 153)。

aws personalize describe-dataset-import-job \ --dataset-import-job-arn arn:aws:personalize:us-west-2:acct-id:dataset-import-job/MovieRatingImportJob

这将显示数据集导入作业的属性,包括其状态。最初,status 显示为 CREATE PENDING,例如:

{ "datasetImportJob": { "jobName": "MovieRatingImportJob", "datasetImportJobArn": "arn:aws:personalize:us-west-2:acct-id:dataset-import-job/MovieRatingImportJob", "datasetArn": "arn:aws:personalize:us-west-2:acct-id:dataset/MovieRatingDatasetGroup/INTERACTIONS", "dataSource": { "dataLocation": "s3://<bucketname>/ratings.csv" }, "roleArn": "role-arn", "status": "CREATE PENDING", "creationDateTime": 1542392161.837, "lastUpdatedDateTime": 1542393013.377 }}

当状态显示为 ACTIVE 时,数据集导入完成。然后,您可以使用指定的数据集来训练模型。

Note

导入需要耗费时间。等待数据集导入完成,然后使用数据集训练模型。

26

Page 31: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门 (AWS CLI)

步骤 2:创建解决方案(训练模型)最初训练模型需要两个步骤。首先,您使用 CreateSolution (p. 123)操作创建用于训练模型的配置。其次,您使用 CreateSolutionVersion (p. 128)操作来训练模型。

您使用配方和您的训练数据来训练模型。Amazon Personalize 提供了一组预定义的配方。有关更多信息,请参阅使用预定义配方 (p. 50)。对于本练习,您使用 AutoML,它允许 Amazon Personalize 根据您在上一步中创建的数据集选择最佳配方。

1. 通过运行以下命令创建用于训练模型的配置。

aws personalize create-solution \ --name MovieSolution \ --dataset-group-arn arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieRatingDatasetGroup \ --perform-auto-ml

这将显示解决方案 ARN,例如:

{ "solutionArn": "arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution"}

2. 使用 describe-solution 命令检查创建状态。提供上一步中返回的解决方案 ARN。有关 API 的更多信息,请参阅 DescribeSolution (p. 163)。

aws personalize describe-solution \ --solution-arn arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution

这将显示解决方案的属性和创建 status。最初,状态显示为 CREATE PENDING,例如:

{ "solution": { "name": "MovieSolution", "solutionArn": "arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution", "datasetGroupArn": "arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieRatingDatasetGroup", "performAutoML": true, "performHPO": false, "solutionConfig": { "autoMLConfig": { "metricName": "precision_at_25", "recipeList": [ "arn:aws:personalize:::recipe/aws-hrnn" ] } }, "creationDateTime": 1543864685.016, "lastUpdatedDateTime": 1543864685.016, "status": "CREATE PENDING" }}

请注意 metricName 和 recipeList。由于您指定了 performAutoML,因此 Amazon Personalize将从列表中选择优化该指标的配方。由于我们没有提供任何元数据,因此列表中的唯一配方是HRNN (p. 52) 配方。

当创建 status 显示为 ACTIVE 时,解决方案配置已完成,模型已经准备好进行训练。3. 既然配置处于 ACTIVE 状态,就可以通过运行以下命令来训练模型。

27

Page 32: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门 (AWS CLI)

aws personalize create-solution-version \ --solution-arn arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution

这将显示解决方案版本 ARN,例如:

{ "solutionVersionArn": "arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/<version-id>"}

使用 describe-solution-version 命令检查解决方案版本的训练状态。提供上一步中返回的解决方案版本 ARN。有关 API 的更多信息,请参阅 DescribeSolutionVersion (p. 166)。

aws personalize describe-solution-version \ --solution-version-arn arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/version-id

将显示解决方案版本的属性和训练 status。最初,状态显示为 CREATE PENDING,例如:

{ "solutionVersion": { "solutionVersionArn": "arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/<version-id>", ..., "status": "CREATE PENDING" }}

4. 当最新解决方案版本训练 status 显示为 ACTIVE 时,训练完成。describe-solution-version 响应现在包含 recipeArn,其显示了由 Amazon Personalize 确定用于训练模型的配方,例如:

{ "solutionVersion": { "solutionVersionArn": "arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/<version-id>", "performAutoML": true, "recipeArn": "arn:aws:personalize:::recipe/aws-hrnn", "solutionConfig": { "autoMLConfig": { "metricName": "precision_at_25", "recipeList": [ "arn:aws:personalize:::recipe/aws-hrnn" ] } }, ... "status": "ACTIVE" }}

现在您可以检查解决方案版本指标并使用解决方案版本创建市场活动。

Note

训练需要时间。在活动中使用此版本的解决方案之前,等待训练完成(解决方案的训练状态显示为 ACTIVE)。要加快训练速度,请使用 recipe-arn 参数选择特定配方,而不是使用perform-auto-ml。

28

Page 33: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门 (AWS CLI)

5. 您可通过检查解决方案版本的指标来验证解决方案的性能。通过运行以下命令来获取解决方案版本的指标。提供之前返回的解决方案版本 ARN。有关 API 的更多信息,请参阅GetSolutionMetrics (p. 169)。

aws personalize get-solution-metrics \ --solution-version-arn arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/version-id

此时将显示示例响应:

{ "solutionVersionArn": "arn:aws:personalize:us-west-2:acct-id:solution/www-solution/<version-id>", "metrics": { "arn:aws:personalize:us-west-2:acct-id:model/awspersonalizehrnnmodel-7923fda9": { "coverage": 0.27, "mean_reciprocal_rank_at_25": 0.0379, "normalized_discounted_cumulative_gain_at_5": 0.0405, "normalized_discounted_cumulative_gain_at_10": 0.0513, "normalized_discounted_cumulative_gain_at_25": 0.0828, "precision_at_5": 0.0136, "precision_at_10": 0.0102, "precision_at_25": 0.0091 } }}

步骤 3:创建活动(部署解决方案)您必须先部署解决方案的版本,然后才能获得推荐。部署解决方案也称为创建活动。一旦您创建活动,您的客户端应用程序就可以使用 GetRecommendations (p. 204) API 获得推荐。

1. 通过运行以下命令来创建活动。提供上一步中返回的解决方案版本 ARN。有关 API 的更多信息,请参阅CreateCampaign (p. 106)。

aws personalize create-campaign \ --name MovieRecommendationCampaign \ --solution-version-arn arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/version-id \ --min-provisioned-tps 10

此时将显示示例响应:

{ "campaignArn": "arn:aws:personalize:us-west-2:acct-id:campaign/MovieRecommendationCampaign"}

2. 通过运行以下命令来检查部署状态。提供上一步中返回的活动 ARN。有关 API 的更多信息,请参阅DescribeCampaign (p. 147)。

aws personalize describe-campaign \ --campaign-arn arn:aws:personalize:us-west-2:acct-id:campaign/MovieRecommendationCampaign

此时将显示示例响应:

{

29

Page 34: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南入门(适用于 Python 的 AWS 开发工具包)

"campaign": { "name": "MovieRecommendationCampaign", "campaignArn": "arn:aws:personalize:us-west-2:acct-id:campaign/MovieRecommendationCampaign", "solutionVersionArn": "arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/<version-id>", "minProvisionedTPS": "10", "creationDateTime": 1543864775.923, "lastUpdatedDateTime": 1543864791.923, "status": "CREATE IN_PROGRESS" }}

Note

在获得来自活动的推荐之前,等待 status 显示为“ACTIVE”。

步骤 4:获得推荐通过运行 get-recommendations 命令来获得推荐。提供上一步中返回的活动 ARN。在请求中,指定电影评级数据集中的用户 ID。有关 API 的更多信息,请参阅GetRecommendations (p. 204)。

Note

并非所有配方都支持 GetRecommendations API。有关更多信息,请参阅使用预定义配方 (p. 50)。您在此步骤中调用的 AWS CLI 命令 personalize-runtime 与您在之前的步骤中所调用的不同。

aws personalize-runtime get-recommendations \ --campaign-arn arn:aws:personalize:us-west-2:acct-id:campaign/MovieRecommendationCampaign \ --user-id 123

在响应中,活动将返回用户可能喜欢的项目推荐(电影 ID)的列表。此列表按用户的相关性进行降序排序。

{ "itemList": [ { "itemId": "14" }, { "itemId": "15" }, { "itemId": "275" }, { "itemId": "283" }, { "itemId": "273" }, ... ]}

入门(适用于 Python 的 AWS 开发工具包)本主题介绍如何使用 适用于 Python 的 AWS 开发工具包 (Boto3) 开始 Amazon Personalize 编程。

30

Page 35: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南先决条件

先决条件以下是使用本指南中的 Python 示例的先决条件步骤:

• 完成入门先决条件 (p. 11)。您可以使用入门(控制台) (p. 12)或入门 (AWS CLI) (p. 23) 练习中列出的相同源数据。如果您使用自己的源数据,请确保按照先决条件步骤创建训练数据 (p. 11)中那样对数据进行了格式化。有关准备您自己的源数据的信息,请参阅准备和导入数据 (p. 33)。

• 设置您的 适用于 Python 的 AWS 开发工具包 (Boto3) 环境,如设置 AWS 开发工具包 (p. 9)中所指定。

完成本练习后,为避免产生不必要的费用,请删除您创建的资源。有关更多信息,请参阅 清理资源 (p. 32)。

步骤 1:验证 Python 环境在完成先决条件之后,请运行以下 Python 示例,以确认您的环境已正确配置。如果已正确配置环境,则会显示可用配方的列表,您现在可以运行本指南中的其他 Python 示例。

import boto3

personalize = boto3.client('personalize')

response = personalize.list_recipes()

for recipe in response['recipes']: print (recipe)

步骤 2:导入训练数据在验证已正确配置 Python 环境之后,请导入您的数据。要将数据集用于训练,您需要执行以下操作:

1. 添加架构。该架构允许 Amazon Personalize 解析训练数据集。有关代码示例,请参阅数据集和架构 (p. 33)。

2. 导入数据。创建一个数据集组,其中包含 Amazon Personalize 可用于训练的一个或多个数据集。有关代码示例,请参阅使用 AWS Python 开发工具包导入数据 (p. 40)。

3. (可选)添加事件跟踪器。要添加事件来训练模型,您必须添加跟踪 ID 以将事件与您的数据集组关联。有关代码示例,请参阅获取跟踪 ID (p. 43)。

4. (可选)添加事件记录。要在训练中添加更多数据并创建更好的模型,您可以使用事件。事件是记录的用户活动,例如搜索、查看或购买。有关代码示例,请参阅PutEvents 操作 (p. 45)。

步骤 3:创建解决方案导入数据后,请创建解决方案和解决方案版本。该解决方案 包含用于训练模型的配置。解决方案版本 是经过训练的模型。有关代码示例,请参阅创建解决方案 (p. 48)。

在您创建解决方案版本时,请在继续前评估其性能。有关代码示例,请参阅评估解决方案版本 (p. 69)。

步骤 4:创建活动训练和评估解决方案版本之后,您可以使用活动来部署它。活动是用于托管解决方案版本并向用户提出建议的终端节点。有关代码示例,请参阅创建活动 (p. 72)。

步骤 5:获得推荐创建活动之后,您可以使用它来获得推荐。有关代码示例,请参阅GetRecommendations (p. 73)。

31

Page 36: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南(可选)使用 Jupyter (iPython) 笔记本探索 Amazon Personalize API

(可选)使用 Jupyter (iPython) 笔记本探索 AmazonPersonalize API我们提供了一个 Jupyter (iPython) 笔记本来帮助您探索 Amazon Personalize API。除一点之外,Jupyter 笔记本与本指南中的 Python 示例具有相同的先决条件。笔记本使用不同的源数据,并且您无需执行先决条件步骤创建训练数据 (p. 11)。

要获取 Jupyter 笔记本,请从 Amazon Personalize 示例存储库克隆或下载personalize_sample_notebook.ipynb 笔记本。

清理资源为避免产生不必要的费用,请删除完成入门练习后创建的资源。要删除资源,请使用 Amazon Personalize控制台或开发工具包中的 Delete API 或 AWS Command Line Interface (AWS CLI)。例如,使用DeleteCampaign (p. 131) API 来删除活动。

您无法删除其状态为 CREATE PENDING 或 IN PROGRESS 的资源。资源状态必须为 ACTIVE 或 CREATEFAILED。使用 Describe API 检查状态,例如 DescribeCampaign (p. 147)。

有些资源必须在其他资源之前删除,如下表所示。此过程可能需要一些时间。

要删除您上传的训练数据 ratings.csv,请参阅如何从 S3 存储桶中删除对象?。

要删除的资源 首先删除此项 备注

Campaign (p. 221)    

DatasetImportJob (p. 235)   无法删除。

EventTracker (p. 249)   与事件跟踪器关联的事件-交互数据集不会被删除,并将继续由解决方案版本使用。

Dataset (p. 229)   无关联的 DatasetImportJob 可以处于CREATE PENDING 或 IN PROGRESS 状态。

无关联的 SolutionVersion 可以处于CREATE PENDING 或 IN PROGRESS 状态。

DatasetSchema (p. 239) 引用架构的所有数据集。  

Solution (p. 265) 所有基于解决方案版本的市场活动。

无关联的 SolutionVersion 可以处于CREATE PENDING 或 IN PROGRESS 状态。

SolutionVersion (p. 272)   删除关联的 Solution 时会被删除。

DatasetGroup (p. 231) 所有关联的事件跟踪程序。

所有关联的解决方案。

数据集组中的所有数据集。

32

Page 37: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南数据集和架构

准备和导入数据Amazon Personalize 使用您提供的数据来训练模型。您可提供源文件中的数据,也可从实时事件(如网站上的用户活动)收集数据。

如果您提供了将数据导入 Amazon Personalize 的源文件,则必须满足以下要求:

• 将数据格式化为逗号分隔值 (CSV) 文件• 提供架构,以便 Amazon Personalize 可以正确地导入数据• 将您的文件上传到 Amazon Personalize 可以访问的 Amazon Simple Storage Service (Amazon S3) 存储

您可使用适用于 Python 的 AWS 开发工具包来上传数据。

此部分提供有关设置历史数据格式并将历史数据导入 Amazon Personalize 的信息。有关记录实时事件数据的信息,请参阅记录事件 (p. 43)。

主题• 数据集和架构 (p. 33)• 为您的输入数据设置格式 (p. 39)• 上传至 S3 存储桶 (p. 40)• 导入数据 (p. 40)

数据集和架构Amazon Personalize 可识别三种类型的历史数据集。每种类型都有相关的架构,其名称 键的值与数据集类型匹配。三种类型是:

• 用户 – 此数据集旨在提供有关用户的元数据。这可能包括年龄、性别或会员资格等信息,这些信息可能是个性化系统中的重要信号。

• 项目 – 此数据集旨在提供有关项目的元数据。这可能包括如价格、SKU 类型或可用性等信息。• 交互 – 此数据集旨在提供用户和项目之间的历史交互数据。该数据集还可提供有关用户浏览背景的元数

据,例如用户所在的位置或所用的设备(移动设备、平板电脑、台式机等)。

用户和项目数据集类型称为元数据类型,仅供某些配方使用。有关更多信息,请参阅 使用预定义配方 (p. 50)。对于元数据数据集,除 USER_ID 和 ITEM_ID 之外的所有其他字符串都必须在架构中标记为categorical,如以下示例所示。

Note

数据集组只能包含每种数据集类型中的一种。

每个数据集都具有一组必填字段、保留关键字及其所需的数据类型,如下表所示。

数据集类型 必填字段 保留关键字

用户 USER_ID (string)

1 个元数据字段

 

项目 ITEM_ID (string)

1 个元数据字段

 

33

Page 38: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南数据集和架构

数据集类型 必填字段 保留关键字

交互 USER_ID (string)

ITEM_ID (string)

TIMESTAMP (long)

EVENT_TYPE (string)

EVENT_VALUE (float)

在将数据集添加到 Amazon Personalize 之前,您必须定义该数据集的架构。每个数据集类型都有特定的要求。Amazon Personalize 中的架构以 Avro 格式定义。有关更多信息,请参阅 Apache Avro。

当您创建架构时,您必须遵循以下这些准则:

• 架构字段可以采用任何顺序,但它们必须与数据文件中的对应列标题的顺序匹配。• 每个数据集类型需要其架构中的特定字段。您必须定义必填字段及其所需的数据类型。• 有些架构将保留关键字用于字段名称。如果您对架构中的字段名称使用保留关键字,则必须将其定义为所

需的数据类型。• 必填字段和保留关键字不会被视为“元数据字段”。• 所添加的不需要的字段或不使用保留关键字的字段是元数据。元数据字段可以是字符串或非字符串类型。• 用户和项目架构至少需要一个元数据字段。• 如果您添加您自己的类型为 string 的元数据字段,它必须包含 "categorical" 属性。否则,您无法使

用它来训练模型。• “用户”或“交互”数据集最多可包含 5 个元数据字段。“项目”数据集最多可包含 50 个元数据字段。

以下示例显示了一个交互架构。EVENT_TYPE 和 EVENT_VALUE 字段是可选的,并且是 AmazonPersonalize 可识别的保留关键字。LOCATION 和 DEVICE 是可选的上下文元数据字段。

{ "type": "record", "name": "Interactions", "namespace": "com.amazonaws.personalize.schema", "fields": [ { "name": "USER_ID", "type": "string" }, { "name": "ITEM_ID", "type": "string" }, { "name": "EVENT_TYPE", "type": "string" }, { "name": "EVENT_VALUE", "type": "float" }, { "name": "LOCATION", "type": "string", "categorical": true }, { "name": "DEVICE", "type": "string", "categorical": true },

34

Page 39: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南使用 Python 创建架构

{ "name": "TIMESTAMP", "type": "long" } ], "version": "1.0"}

以下示例显示了一个 Avro 格式的用户架构。仅 USER_ID 字段为必填字段。AGE 和 GENDER 字段是元数据。

{ "type": "record", "name": "Users", "namespace": "com.amazonaws.personalize.schema", "fields": [ { "name": "USER_ID", "type": "string" }, { "name": "AGE", "type": "int" }, { "name": "GENDER", "type": "string", "categorical": true } ], "version": "1.0"}

以下示例显示了一个项目架构。仅 ITEM_ID 字段为必填字段。显示的 GENRE 字段是元数据。

{ "type": "record", "name": "Items", "namespace": "com.amazonaws.personalize.schema", "fields": [ { "name": "ITEM_ID", "type": "string" }, { "name": "GENRE", "type": "string", "categorical": true } ], "version": "1.0"}

如果您使用的是 AWS 控制台,则在为输入数据创建数据集时创建一个新架构。您也可以选择现有架构。有关更多信息,请参阅 步骤 1:导入训练数据 (p. 12)。

如果您使用的是 AWS CLI,请参阅步骤 1:导入训练数据 (p. 24)获取示例。

使用 AWS Python 开发工具包创建架构1. 定义要使用的 Avro 格式架构。2. 将架构保存在默认 Python 文件夹的 JSON 文件中。

35

Page 40: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南筛选用户-交互训练数据集中的记录

3. 使用以下代码创建架构。

import boto3

personalize = boto3.client('personalize')

with open('schema.json') as f: createSchemaResponse = personalize.create_schema( name = 'YourSchema', schema = f.read() )

schema_arn = createSchemaResponse['schemaArn']

print('Schema ARN:' + schema_arn )

4. Amazon Personalize 返回新架构的 ARN。请将其存储以便将来使用。

Amazon Personalize 提供用于管理架构的操作。例如,您可以使用 ListSchemas (p. 189) API 来获取可用架构的列表。

在创建架构后,将它用于与架构匹配的数据集。有关更多信息,请参阅 为您的输入数据设置格式 (p. 39)。

筛选用户-交互训练数据集中的记录如果您的交互数据集包含您不想用于训练的数据,则可以通过设置值的阈值(如价格)或指定事件类型(如购买或点击)来筛选掉这些记录。通过筛选,您可以仅使用相关的数据子集进行训练,或者去除噪声以训练更优化的模型。

您可以通过两种方式从交互数据集中筛选记录:

• 通过在配方中指定事件值,设置阈值以基于特定值排除记录 - 如果记录包括与特定事件相关联的金额(例如,则用户支付的价格与购买项目相关联),您可以将配方中的特定值设置为从训练中排除记录的阈值。该金额称为事件值。

• 通过在配方中指定事件类型来排除某种类型的记录 – 数据集通常包括特定类型的活动,例如“purchase”、“click” 或 "wishlisted"。这些策略称为事件类型。要仅在训练中包含特定事件类型的记录,请按配方中的事件类型筛选数据集。

同样,交互数据集通常包含特定类型的活动,例如,“purchase”、“click” 或 "wishlisted"。这些策略称为事件类型。要仅在训练中包含特定事件类型的记录,请按配方中的事件类型筛选数据集。

要按事件值或事件类型进行筛选,请为用于创建解决方案的配方创建交互架构。要在训练中使用更具体的子集,还可以按事件值和事件类型筛选数据集。

按事件值和事件类型筛选数据集在以下步骤中,您使用适用于 Python 的 AWS 开发工具包 (Boto3) 创建一个用于筛选训练数据集的交互架构。您可以使用 Jupyter (iPython) 笔记本来完成相同的任务。有关更多信息,请参阅 (可选)使用 Jupyter(iPython) 笔记本探索 Amazon Personalize API (p. 32)。

先决条件:完成先决条件,并验证如入门(适用于 Python 的 AWS 开发工具包) (p. 30)中所述设置了您的Python 环境。

按事件值或事件类型筛选训练数据集中使用的记录

1. 使用 "name" 和 "type" 键值对创建交互架构并包含 EVENT_TYPE 和 EVENT_VALUE 字段,如下所示。

36

Page 41: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南筛选用户-交互训练数据集中的记录

import boto3import json personalize = boto3.client('personalize') # Create a name for your schemaschema_name = 'YourSchemaName' # Define the schema for your datasetschema = { "type": "record", "name": "Interactions", "namespace": "com.amazonaws.personalize.schema", "fields": [ { "name": "USER_ID", "type": "string" }, { "name": "ITEM_ID", "type": "string" }, { "name": "EVENT_VALUE", "type": "float" }, { "name": "EVENT_TYPE", "type": "string" }, { "name": "TIMESTAMP", "type": "long" } ], "version": "1.0"} # Create the schema for Amazon Personalizecreate_schema_response = personalize.create_schema( name = schema_name, schema = json.dumps(schema)) #To get the schema ARN, use the following linesschema_arn = create_schema_response['schemaArn']print('Schema ARN:' + schema_arn )

2. 格式化您的输入数据以匹配您的架构。有关代码示例,请参阅为您的输入数据设置格式 (p. 39)。3. 将数据上传到您的 Amazon Simple Storage Service (Amazon S3) 存储桶。有关代码示例,请参阅上传

至 S3 存储桶 (p. 40)。4. 使用 CreateDatasetImportJob (p. 115) API 将数据导入您的 Amazon Personalize。请务必记录数据

集组 Amazon 资源名称 (ARN),因为在创建解决方案时将需要它。有关代码示例,请参阅使用 AWSPython 开发工具包导入数据 (p. 40)。

5. 获取当您创建解决方案时要使用的配方的 ARN。在创建解决方案时,您将需要它。

import boto3 personalize = boto3.client('personalize')

37

Page 42: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南筛选用户-交互训练数据集中的记录

# Display the ARNs of the recipesrecipe_list = personalize.list_recipes()for recipe in recipe_list['recipes']: print(recipe['recipeArn']) # Store the ARN of the recipe that you want to use recipe_arn = "arn:aws:personalize:::recipe/aws-recipe-name"

6. 调用 CreateSolution (p. 123) API。如果您要指定事件类型(例如 “purchase”),请在 eventType参数中进行设置。如果您要指定事件值(例如 10),请在 eventValueThreshold 参数中进行设置。您还可以同时指定事件类型和事件值。

import boto3 personalize = boto3.client('personalize')

# Create the solutioncreate_solution_response = personalize.create_solution( name = "your-solution-name", datasetGroupArn = dataset_group_arn, recipeArn = recipe_arn, "eventType": "purchase", solutionConfig = { "eventValueThreshold": "10" })

# Store the solution ARNsolution_arn = create_solution_response['solutionArn']

# Use the solution ARN to get the solution statussolution_description = personalize.describe_solution(solutionArn = solution_arn)['solution']print('Solution status: ' + solution_description['status'])

7. 获得解决方案后,通过在 CreateSolutionVersion (p. 128) 请求中指定其解决方案 ARN 使用它来训练模型。

import boto3 personalize = boto3.client('personalize')

# Create a solution versioncreate_solution_version_response = personalize.create_solution_version(solutionArn = solution_arn)

# Store the solution version ARNsolution_version_arn = create_solution_version_response['solutionVersionArn'] # Use the solution version ARN to get the solution version status.solution_version_description = personalize.describe_solution_version( solutionVersionArn = solution_version_arn)['solutionVersion']print('Solution version status: ' + solution_version_description['status'])

当状态为 ACTIVE 时,训练完成。有关更多信息,请参阅 创建解决方案 (p. 48)。

训练模型后,您应评估其性能。要优化您的模型,您可能希望调整 eventValueThreshold 或其他超参数。有关更多信息,请参阅 评估解决方案版本 (p. 69)。

38

Page 43: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南为您的输入数据设置格式

为您的输入数据设置格式您用于将数据导入 Amazon Personalize 的文件必须映射到您所使用的架构。

Amazon Personalize 仅从逗号分隔值 (CSV) 格式的文件导入数据。Amazon Personalize 要求您的 CSV 文件的第一行包含列标题。CSV 文件中的列标题需要映射到此架构以创建数据集。不要将标题括在引号 (")中。

例如,以下 CSV 数据示例会映射到数据集和架构 (p. 33)中显示的交互架构。此数据表示销售电影票的网站上的历史用户活动。您可以使用此数据训练基于其他用户的活动向用户提供电影推荐的模型。

USER_ID,ITEM_ID,EVENT_TYPE,EVENT_VALUE,TIMESTAMP196,242,click,15,881250949186,302,click,13,89171774222,377,click,10,878887116244,51,click,20,880606923166,346,click,10,886397596298,474,click,40,884182806115,265,click,20,881171488253,465,click,50,891628467305,451,click,30,886324817

下面重复关联的交互架构。

{ "type": "record", "name": "Interactions", "namespace": "com.amazonaws.personalize.schema", "fields": [ { "name": "USER_ID", "type": "string" }, { "name": "ITEM_ID", "type": "string" }, { "name": "EVENT_TYPE", "type": "string" }, { "name": "EVENT_VALUE", "type": "float" }, { "name": "TIMESTAMP", "type": "long" } ], "version": "1.0"}

Amazon Personalize 需要 USER_ID、ITEM_ID 和 TIMESTAMP 字段。USER_ID 是应用程序用户的标识符。ITEM_ID 是电影的标识符。EVENT_TYPE 和 EVENT_VALUE 是用户活动的标识符。在示例数据中,click 可能表示电影购买活动事件,15 可能表示电影的购买价格。TIMESTAMP 表示购买电影的 Unix时间。

39

Page 44: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南分类数据

分类数据要在使用分类字符串数据时包含单个项目的多个类别,请使用竖线“|”字符分隔值。例如,要使用两个分类匹配上一节中的项目架构,数据行将与下面类似:

ITEM_ID,GENREitem_123,horror|comedy

设定数据格式后,将其上传到 Amazon S3 存储桶,以便将其导入 Amazon Personalize。有关更多信息,请参阅 上传至 S3 存储桶 (p. 40)。

上传至 S3 存储桶在使用您的数据创建一个 CSV 文件之后,将该文件上传到 Amazon Simple Storage Service (Amazon S3)存储桶。Amazon Personalize 会从其中导入您的数据。

Amazon Personalize 需要访问 S3 存储桶的权限。将以下策略附加到您的存储桶:有关更多信息,请参阅如何添加 S3 存储桶策略?

{ "Version": "2012-10-17", "Id": "PersonalizeS3BucketAccessPolicy", "Statement": [ { "Sid": "PersonalizeS3BucketAccessPolicy", "Effect": "Allow", "Principal": { "Service": "personalize.amazonaws.com" }, "Action": [ "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::bucket-name", "arn:aws:s3:::bucket-name/*" ] } ]}

将数据上传到 S3 存储桶之后,将数据导入 Amazon Personalize。有关更多信息,请参阅 导入数据 (p. 40)。

导入数据要将训练数据导入 Amazon Personalize,首先创建一个空数据集组,然后在该数据集组中创建一个空数据集。接下来,创建使用 Amazon S3 存储桶中的数据填充数据集的导入作业。有关数据集的更多信息,请参阅数据集和架构 (p. 33)。

使用 AWS Python 开发工具包导入数据以下步骤演示如何创建和填充数据集。有关使用 AWS CLI 的等效步骤,请参阅步骤 1:导入训练数据 (p. 24)。

1. 使用 CreateDatasetGroup (p. 112) API 创建数据集组。

40

Page 45: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南使用 Python 导入数据

import boto3

personalize = boto3.client('personalize')

response = personalize.create_dataset_group(name = 'YourDatasetGroup')dsg_arn = response['datasetGroupArn']

description = personalize.describe_dataset_group(datasetGroupArn = dsg_arn)['datasetGroup']

print('Name: ' + description['name'])print('ARN: ' + description['datasetGroupArn'])print('Status: ' + description['status'])

来自 DescribeDatasetGroup (p. 151) API 的响应返回 datasetGroupArn 和操作的状态。

Note

在继续下一个步骤之前,您必须等待,直到状态显示为 ACTIVE。2. 使用 CreateDataset (p. 109) API 创建数据集。指定上一个步骤中返回的 datasetGroupArn。使用

之前在数据集和架构 (p. 33)中创建的 schemaArn。

import boto3

personalize = boto3.client('personalize')

response = personalize.create_dataset( name = 'YourDataset', schemaArn = 'schema_arn', datasetGroupArn = 'dataset_group_arn', datasetType = 'Interactions')

print ('Dataset Arn: ' + response['datasetArn'])

3. 要将数据添加到数据集,请使用 CreateDatasetImportJob (p. 115) API 创建并运行数据集导入作业。指定 datasetGroupArn 并将 dataLocation 设置为用于存储训练数据的 S3 存储桶。

有关 roleArn,请参阅创建 IAM 角色 (p. 7)。roleArn 参数指定向 Amazon Personalize 提供访问 S3存储桶的权限的 AWS Identity and Access Management (IAM) 角色。

import boto3

personalize = boto3.client('personalize')

response = personalize.create_dataset_import_job( jobName = 'YourImportJob', datasetArn = 'dataset_arn', dataSource = {'dataLocation':'s3://bucket/file.csv'}, roleArn = 'role_arn')

dsij_arn = response['datasetImportJobArn']

print ('Dataset Import Job arn: ' + dsij_arn)

description = personalize.describe_dataset_import_job( datasetImportJobArn = dsij_arn)['datasetImportJob']

print('Name: ' + description['jobName'])print('ARN: ' + description['datasetImportJobArn'])print('Status: ' + description['status'])

41

Page 46: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南使用 Python 导入数据

该响应返回 datasetImportJobArn。来自 DescribeDatasetImportJob (p. 153) API 的响应包含操作的状态。

Note

您必须等待,直到状态更改为 ACTIVE,然后才能使用数据训练模型。

Important

Amazon Personalize 中的导入是对数据的完全刷新。您无法添加增量更新。如果您需要更新数据,请导入更新后的完整文件。

Amazon Personalize 提供用于管理数据集、数据集组和数据集导入作业的操作。例如,您可使用ListDatasets (p. 182) 列出数据集组中的数据集,并使用 DeleteDataset (p. 133) 删除数据集。

将您的数据导入到数据集组中的相关数据集后,通过训练模型来创建解决方案版本。有关更多信息,请参阅创建解决方案 (p. 48)。

42

Page 47: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南创建数据集组

记录事件Amazon Personalize 可以完全基于导入的历史数据进行推荐,如入门 (p. 11)指南中所示。AmazonPersonalize 还可以使用 Amazon Personalize 事件提取开发工具包完全根据实时事件数据或两者的组合进行推荐。

与历史数据不同,在创建活动后,在从活动获取建议时将自动使用新的已记录的事件数据。

Note

训练模型的最低数据要求为:

• 1000 条组合交互数据记录(按 eventType 和 eventValueThreshold 筛选之后,如果提供)• 25 个唯一用户,每个用户至少 2 个交互

事件提取开发工具包包含一个用于记录 Web 客户端应用程序中的事件的 JavaScript 库。该开发工具包还包含一个用于记录服务器代码中的事件的库。

要记录事件,您需要以下项:

• 包含一个 Interactions 数据集的数据集组,该数据集可以为空。• 一个事件跟踪器。• 调用 PutEvents (p. 200) 操作。

Amazon Personalize 预定义配方与 PutEvents API 兼容。这包括所需的 sessionId 参数,这些参数使这些配方可以了解会话。

有关演示如何使用 PutEvents 操作来记录和实施新客户数据的 Jupyter 示例笔记本,请参阅 amazon-personalize-samples GitHub 存储库中的将 PutEvents API 与 Personalize 结合使用。

主题• 创建数据集组 (p. 43)• 获取跟踪 ID (p. 43)• 事件-交互数据集 (p. 44)• PutEvents 操作 (p. 45)• 事件指标 (p. 47)• 事件和解决方案 (p. 47)

创建数据集组如果您浏览了 入门 (p. 11) 指南,则可以使用您创建的同一数据集组。对于创建数据集和数据集组的 Python示例,请参阅 导入数据 (p. 40)。

获取跟踪 ID跟踪 ID 将事件与数据集组关联并授权您将数据发送到 Amazon Personalize。您可以通过调用CreateEventTracker (p. 118) API 并提供数据集组 ARN 来生成跟踪 ID。

43

Page 48: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南事件-交互数据集

Note

只有一个事件跟踪程序可以与数据集组关联。如果您使用相同的数据集组作为现有事件跟踪程序来调用 CreateEventTracker,将收到错误。

Python

import boto3

personalize = boto3.client('personalize')

response = personalize.create_event_tracker( name='MovieClickTracker', datasetGroupArn='arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieClickGroup')print(response['eventTrackerArn'])print(response['trackingId'])

AWS CLI

aws personalize create-event-tracker \ --name MovieClickTracker \ --dataset-group-arn arn:aws:personalize:us-west-2:acct-id:dataset-group/MovieClickGroup

此时将显示事件跟踪器 ARN 和跟踪 ID,例如:

{ "eventTrackerArn": "arn:aws:personalize:us-west-2:acct-id:event-tracker/MovieClickTracker", "trackingId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}

事件-交互数据集当 Amazon Personalize 创建事件跟踪器时,它还会在与事件跟踪器关联的数据集组中创建事件-交互数据集。该事件-交互数据集存储来自 PutEvents (p. 200) 调用的事件数据。数据集的内容对用户不可用。

要查看数据集的属性,请调用 ListDatasets (p. 182) API,并提供数据集组 ARN。有关数据集的更多信息,请使用 EVENT_INTERACTIONS 的数据集的 ARN 来调用 DescribeDataset (p. 149) API。以下是来自ListDatasets 的示例响应:

{ "datasets": [ { "name": "ratings-dsgroup/EVENT_INTERACTIONS", "datasetArn": "arn:aws:personalize:us-west-2:acct-id:dataset/MovieClickGroup/EVENT_INTERACTIONS", "datasetType": "EVENT_INTERACTIONS", "status": "ACTIVE", "creationDateTime": 1554304597.806, "lastUpdatedDateTime": 1554304597.806 }, { "name": "ratings-dataset",

44

Page 49: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南PutEvents 操作

"datasetArn": "arn:aws:personalize:us-west-2:acct-id:dataset/MovieClickGroup/INTERACTIONS", "datasetType": "INTERACTIONS", "status": "ACTIVE", "creationDateTime": 1554299406.53, "lastUpdatedDateTime": 1554299406.53 } ], "nextToken": "..."}

PutEvents 操作要记录事件,请调用 PutEvents (p. 200) 操作。以下示例显示传递一个包含最少必需信息的事件的PutEvents 调用。将显示对应的 Interactions 架构,以及 Interactions 数据集中的一个示例行。

会话 ID 对于您的应用程序是自定义的。事件列表是 Event (p. 278) 对象的数组。properties 键是特定于事件的数据的字符串映射(键-值对)。在这种情况下,只需指定项目 ID。

userId、itemId 和 sentAt 参数映射到相应的历史 Interactions 数据集的 USER_ID、ITEM_ID 和TIMESTAMP 字段。有关更多信息,请参阅 数据集和架构 (p. 33)。

Note

您还可以使用 AWS Amplify 将事件数据发送到 Amazon Personalize。有关更多信息,请参阅Amplify - 分析。

Interactions schema: USER_ID, ITEM_ID, TIMESTAMPInteractions dataset: user123, item-xyz, 1543631760

Python

import boto3

personalize_events = boto3.client(service_name='personalize-events')

personalize_events.put_events( trackingId = 'tracking_id', userId= 'USER_ID', sessionId = 'session_id', eventList = [{ 'sentAt': TIMESTAMP, 'eventType': 'EVENT_TYPE', 'properties': "{\"itemId\": \"ITEM_ID\"}" }])

AWS CLI

aws personalize-events put-events \ --tracking-id tracking_id \ --user-id USER_ID \ --session-id session_id \ --event-list '[{ "sentAt": "TIMESTAMP", "eventType": "EVENT_TYPE", "properties": "{\"itemId\": \"ITEM_ID\"}" }]'

45

Page 50: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南PutEvents 操作

在本示例中,您将仅使用所需属性来继续训练模型。该训练不使用 eventValue 属性,因为它未包含在事件中。

下一个示例说明如何提交对事件值进行训练的数据。它还演示如何传递多个不同类型(“喜欢”和“评级”)的事件。在这种情况下,您必须在 CreateSolution (p. 123) 操作中指定训练所基于的事件类型(参阅事件和解决方案)。还显示了由某些配方用作元数据的额外属性 numRatings 的记录。

Interactions schema: USER_ID, ITEM_ID, TIMESTAMP, EVENT_TYPE, EVENT_VALUE, NUM_RATINGSInteractions dataset: user123, movie_xyz, 1543531139, rating, 5, 12 user321, choc-ghana, 1543531760, like, true user111, choc-fake, 1543557118, like, false

Python

import boto3import json

personalize_events = boto3.client(service_name='personalize-events')

personalize_events.put_events( trackingId = 'tracking_id', userId= 'user555', sessionId = 'session1', eventList = [{ 'eventId': 'event1', 'sentAt': '1553631760', 'eventType': 'like', 'properties': json.dumps({ 'itemId': 'choc-panama', 'eventValue': 'true' }) }, { 'eventId': 'event2', 'sentAt': '1553631782', 'eventType': 'rating', 'properties': json.dumps({ 'itemId': 'movie_ten', 'eventValue': '4', 'numRatings': '13' }) }])

AWS CLI

aws personalize-events put-events \ --tracking-id tracking_id \ --user-id user555 \ --session-id session1 \ --event-list '[{ "eventId": "event1", "sentAt": "1553631760", "eventType": "like", "properties": "{\"itemId\": \"choc-panama\", \"eventValue\": \"true\"}" }, { "eventId": "event2", "sentAt": "1553631782", "eventType": "rating", "properties": "{\"itemId\": \"movie_ten\", \"eventValue\": \"4\", \"numRatings\": \"13\"}" }]'

46

Page 51: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南事件指标

Note

属性键使用与交互架构中的字段匹配的采用驼峰式大小写的名称。例如,如果在交互架构中定义了字段“ITEM_ID”、“EVENT_VALUE”和“NUM_RATINGS”,则属性键应为 itemId, eventValue,and numRatings。

事件指标要监控发送到 Amazon Personalize 的事件的类型和数量,请使用 Amazon CloudWatch 指标。有关更多信息,请参阅 监控 Amazon Personalize (p. 90)。

事件和解决方案在训练使用事件数据的模型时,CreateSolution (p. 123) 操作的两个参数是相关的。在记录多个事件类型时,必须指定 eventType 参数。eventType 指示 Amazon Personalize 将哪种类型的事件用作模型训练的标签。

SolutionConfig 对象的 eventValueThreshold 参数会创建事件筛选器。在指定此参数时,仅具有大于或等于阈值的值的事件用于训练模型。使用 eventValueThreshold 时必须指定事件类型。

47

Page 52: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

创建解决方案解决方案版本是 Amazon Personalize 用于向客户提供推荐的训练后的机器学习模型的术语。创建解决方案需要优化模型以针对特定业务需求交付最佳结果。Amazon Personalize 使用“配方”创建这些个性化解决方案。

Amazon Personalize 中的配方由带超参数的算法和特征转换组成。算法是训练后成为模型的数学表达式。该算法包含一些参数,这些参数的未知值是通过对输入数据进行训练来确定的。超参数是算法的外部参数,它指定了训练过程的详细信息,例如,要在整个数据集上运行的训练扫描的数量或要使用的隐藏层的数量。

Amazon Personalize 提供了大量预定义配方,这些配方可让您在不了解机器学习的情况下提供推荐。预定义配方对快速实验也很有用。有关更多信息,请参阅 使用预定义配方 (p. 50)。

解决方案是通过调用 CreateSolution (p. 123) 和 CreateSolutionVersion (p. 128) 操作创建的。CreateSolution 将创建用于训练模型的配置。CreateSolutionVersion 将启动训练过程,这将生成特定版本的解决方案。每当您调用 CreateSolutionVersion 时,就会创建一个新版本的解决方案。此时将显示 CreateSolution 请求的精简、重组版本。以下部分讨论了各种选项和配置对象。

{ "name": "string", "datasetGroupArn": "string", "performAutoML": boolean, "recipeArn": "string", "performHPO": boolean, "eventType": "string", "solutionConfig": { "autoMLConfig": { "metricName": "string", "recipeList": [ "string" ] }, "eventValueThreshold": "string", "algorithmHyperParameters": { }, "featureTransformationParameters": { }, "hpoConfig": { } },}

下表显示了选择配方的方式。必须指定 performAutoML 或 recipeArn,但不能同时指定二者。仅使用HRNN 配方执行 AutoML。

performAutoML recipeArn solutionConfig 结果

true 忽略 已忽略 Amazon Personalize 选择配方

true 忽略 autoMLConfig:指定了metricName 和 recipeList

Amazon Personalize 从列表中选择优化指标的配方

忽略 满足指定 已忽略 您指定配方

忽略 满足指定 满足指定 您指定配方并覆盖默认训练属性

Note

当 performAutoML 为 true 时,将忽略 solutionConfig 对象的所有参数,autoMLConfig 除外。

48

Page 53: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

将其保留为 Amazon Personalize

如果您不了解机器学习,或者只是想尽快开始,则可以让 Amazon Personalize 分析您的数据并决定要使用的最佳预定义配方和选项。在这种情况下,您调用 CreateSolution 操作,为 performAutoML 参数指定true,然后忽略 recipeArn 和 solutionConfig 参数。Amazon Personalize 将完成剩余操作。

您还可以指定 Amazon Personalize 检查的配方列表,以根据指定的指标决定最佳配方。在这种情况下,您调用 CreateSolution 操作,为 performAutoML 参数指定 true,忽略 recipeArn 参数,包含solutionConfig 参数,并指定 metricName 和 recipeList 作为 autoMLConfig 对象的一部分。

您可以手动选择配方,而不必让 Amazon Personalize 执行此操作。在这种情况下,您调用CreateSolution API,为 performAutoML 指定“false”,并提供 recipeArn 参数。有关预定义配方的列表,请参阅使用预定义配方 (p. 50)。

自定义训练

要自定义训练,请提供 solutionConfig 参数。SolutionConfig 对象可让您覆盖默认解决方案和配方参数。有关更多信息,请参阅覆盖默认配方参数 (p. 66)。

使用 AWS Python 开发工具包创建解决方案版本

1. 创建数据集将其导入数据集组。有关更多信息,请参阅 准备和导入数据 (p. 33)。2. 使用数据集组和以下代码创建解决方案版本。

import boto3

personalize = boto3.client('personalize')

print ('Creating solution')response = personalize.create_solution( name = "SolutionName", datasetGroupArn = "Dataset group arn", performAutoML = True)

# Get the solution ARN.solution_arn = response['solutionArn']print('Solution ARN: ' + solution_arn)

# Use the solution ARN to get the solution status.solution_description = personalize.describe_solution(solutionArn = solution_arn)['solution']print('Solution status: ' + solution_description['status'])

# Use the solution ARN to create a solution version.print ('Creating solution version')response = personalize.create_solution_version(solutionArn = solution_arn)solution_version_arn = response['solutionVersionArn']print('Solution version ARN: ' + solution_version_arn)

# Use the solution version ARN to get the solution version status.solution_version_description = personalize.describe_solution_version( solutionVersionArn = solution_version_arn)['solutionVersion']print('Solution version status: ' + solution_version_description['status'])

训练模型需要时间。要检查当前解决方案版本状态,请调用 DescribeSolutionVersion (p. 166) 操作并传递从 CreateSolutionVersion 操作返回的解决方案版本的 ARN。当 status 为 ACTIVE 时,训练完成。

既然您有一个解决方案版本,请使用 Amazon Personalize 提供的指标评估它。有关更多信息,请参阅 评估解决方案版本 (p. 69)。

49

Page 54: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南使用预定义配方

使用预定义配方Amazon Personalize 根据常见用例为训练模型提供预定义的配方。配方 是一种机器学习算法或算法变体,可以与设置或超参数以及数据集组一起使用来训练 Amazon Personalize 模型。借助配方,您可以创建个性化系统,而不必事先具备机器学习经验。

预定义的配方在训练期间使用以下内容:

• 数据的预定义属性• 预定义特征转换• 预定义算法• 算法的初始参数设置

为了优化模型,您可以在创建解决方案时覆盖上述多个参数。有关更多信息,请参阅 超级参数和HPO (p. 67)。

Amazon Personalize 可以根据其输入数据的分析自动选择最合适的分层循环神经网络 (HRNN) 配方。该选项称为 AutoML。要执行 AutoML,请在调用 CreateSolution (p. 123) API 时将 performAutoML 参数设置为true。或者,您也可以根据要实现的操作以及对这些配方的熟悉程度来选择特定的配方。每个配方都是针对特定用例设计的。创建解决方案时,请选择最适合您需求的配方。

查看可用配方列表:

• 在 Amazon Personalize 控制台中,选择一个数据集组。在导航窗格中,选择 Solutions and recipes (解决方案和配方),然后选择 Recipes (配方) 选项卡。

• 使用适用于 Python 的 AWS 开发工具包 (Boto3),调用 ListRecipes (p. 187) API。• 使用 AWS CLI 运行以下命令。

aws personalize list-recipes

要使用适用于 Python 的 开发工具包 (Boto3) 获取有关配方的信息,请调用 DescribeRecipe (p. 159) API。要使用 AWS CLI 获取有关配方的信息,请使用以下命令。

aws personalize describe-recipe --recipe-arn recipe_arn

Amazon Personalize 提供了三种类型的配方。除了行为差异外,每种类型对获取推荐都有不同的要求,如下表所示。

配方类型 API 要求

USER_PERSONALIZATION GetRecommendations (p. 204) userId:必需

itemId:可选

inputList:不适用

PERSONALIZED_RANKING GetPersonalizedRanking (p. 202) userId:必需

itemId:不适用

inputList:itemId 的列表

50

Page 55: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南预定义配方

配方类型 API 要求

RELATED_ITEMS GetRecommendations (p. 204) userId:未使用

itemId:必需

inputList:不适用

预定义配方Amazon Personalize 提供以下预定义配方。它们按配方类型列出。

用户个性化配方

用户个性化配方可预测用户将与之交互的项目。HRNN (p. 52)^

HRNN 是一种分层循环神经网络,可以在给定时间范围内对用户-项目交互进行建模。当用户行为随时间变化(这称为不断变化的意图问题)时,请使用 HRNN 配方。

为了训练模型,HRNN 将使用数据集组中的交互数据集。数据集组是一组相关的数据集,其可以包括用户、项目和交互数据集。

HRNN 元数据 (p. 54)^*

HRNN 元数据是 HRNN 配方,具有从交互、用户和项目数据集中找到的元数据派生的其他特征。例如,评级、电影类别或发行年份。训练数据必须将元数据包含在至少一个数据集中。当有高质量元数据可用时,HRNN 元数据的执行效果优于非元数据模型。使用该配方进行训练可能需要更长的训练时间。

为了训练模型,HRNN 元数据将使用数据集组中的用户、项目和交互数据集。数据集组是一组相关的数据集,其可以包括用户、项目和交互数据集。

HRNN-Coldstart (p. 57)^*

HRNN 冷启动配方与 HRNN 元数据配方相似,但还包括个性化的新项目探索。当您经常向目录中添加新项目并且希望立即将这些项目包含在推荐中时,请使用 HRNN 冷启动配方。

为了训练模型,HRNN 冷启动将使用数据集组中的用户、项目和交互数据集。数据集组是一组相关的数据集,其可以包括用户、项目和交互数据集。提供训练数据的数据集组必须包含项目数据集。

热门程度-计数 (p. 60)

热门程度计数配方根据交互数据集中针对该项目的事件计数来计算项目的热门程度。可以使用热门程度计数配方创建基准,以便将结果与其他用户个性化配方进行比较。

为了训练模型,热门程度计数配方将使用数据集组中的交互数据集。数据集组是一组相关的数据集,其可以包括用户、项目和交互数据集。

个性化排名配方

个性化排名配方可个性化结果。个性化-排名 (p. 61)

个性化排名配方是一种分层循环神经网络 (HRNN) 配方,它也可以筛选和重新排列结果。个性化排名提供最佳推荐列表。当为用户个性化结果(例如对搜索结果或整理列表进行个性化的重新排名)时,请使用个性化排名配方。

51

Page 56: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN

为了训练模型,个性化排名配方将使用数据集组中的交互数据集。数据集组是一组相关的数据集,其可以包括用户、项目和交互数据集。

相关项目配方

相关项目配方 SIMS 返回与给定项目相似的项目。SIMS (p. 63)

项目与项目相似性 (SIMS) 基于用户-项目交互数据集中的用户历史记录中的项目的共同出现,生成与给定项目相似的项目。如果项目没有足够的用户行为数据,或者如果找不到指定的项目 ID,该配方将返回热门项目作为推荐。使用 SIMS 配方可改进项目的可发现性和详细信息页面。与其他配方相比,使用 SIMS 配方可更快完成训练。

为了训练模型,SIMS 配方将使用数据集组中的交互数据集。数据集组是一组相关的数据集,其可以包括用户、项目和交互数据集。

^ Amazon Personalize 在执行 AutoML 时会考虑这些配方。

* 元数据模型:这些配方在用户交互数据和元数据上进行训练。有关更多信息,请参阅 数据集和架构 (p. 33)。

HRNN 配方Amazon Personalize 分层递归神经网络 (HRNN) 配方模型改变用户行为以在会话期间提供推荐。会话是给定时间范围内的一组用户交互,例如,其目标是找到满足需求的特定项目。通过将用户最近交互的权重提高,您可以在会话期间提供更相关的建议。

HRNN 适用于可随时间变化的用户意图和兴趣。它获取有序的用户历史记录并自动对它们进行加权以做出更好的推论。HRNN 使用门控机制将折扣权重建模为项目和时间戳的可学习函数。

Amazon Personalize 从数据集中为每个用户派生特征。如果您已完成实时数据集成,则会根据用户活动实时更新这些特征。要获取建议,您只需提供 USER_ID。如果您还提供了 ITEM_ID,则Amazon Personalize 将忽略此参数。

HRNN 配方具有以下属性:

• 名称 – aws-hrnn• 配方 Amazon 资源名称 (ARN) – arn:aws:personalize:::recipe/aws-hrnn• 算法 ARN – arn:aws:personalize:::algorithm/aws-hrnn• 功能转换 ARN – arn:aws:personalize:::feature-transformation/JSON-percentile-filtering

• 配方类型 – USER_PERSONALIZATION

下表描述 HRNN 配方的超参数。超参数 是一个算法参数,您可以调整该参数以提高模型性能。算法超参数控制模型的执行方式。特征化超参数控制如何筛选训练中使用的数据。为超参数选择最佳值的过程称为超参数优化 (HPO)。有关更多信息,请参阅 超级参数和 HPO (p. 67)。

该表还为每个超参数提供以下信息:

• 范围:[上界, 下界]• 值类型:Integer、Continuous(浮点数)、Categorical(布尔值、列表、字符串)• 可调 HPO:该参数是否可以参与 HPO?

52

Page 57: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN

名称 描述

算法超参数

hidden_dimension 模型中使用的隐藏变量的数量。隐藏变量 重新创建用户的购买历史记录和项目统计数据来生成排名分数。当交互数据集包含更复杂的模式时,请指定更多数量的隐藏维度。使用更多隐藏维度需要更大的数据集和更多的处理时间。要确定最佳值,请使用 HPO。要使用 HPO,当您调用 CreateSolution (p. 123)和 CreateSolutionVersion (p. 128) 操作时,请将performHPO 设置为 true。

默认值:43

范围:[32, 256]

值类型:整数

HPO 可调:是

bptt 确定是否使用基于时间的反向传播技术。反向传播 是一种在基于递归神经网络的算法中更新权重的技术。将 bptt 用于长期积分以将延迟奖励与早期事件联系起来。例如,延迟奖励可以是几次点击后进行的购买。早期事件可以是初始点击。即使在相同的事件类型(例如点击)中,最好考虑长期影响并最大化总奖励。要考虑长期效果,请使用较大的bptt 值。使用较大的 bptt 值需要更大的数据集和更多的处理时间。

默认值:32

范围:[2, 32]

值类型:整数

HPO 可调:是

recency_mask 确定模型是否应考虑交互数据集中的最新流行趋势。最新流行趋势可能包括交互事件的基本模式的突然变化。要训练一个使最近事件具有更高权重的模型,请将 recency_mask设置为 true。要训练一个使所有过往交互占相同权重的模型,请将 recency_mask 设置为 false。要使用相等权重获得好的建议,您可能需要较大的训练数据集。

默认值:True

范围:True 或 False

值类型:布尔值

HPO 可调:是

特征化超参数

min_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最小百分位数。历史记录长度 是有关用户的数据总量。使用min_user_history_length_percentile 排除历史记录长度较短的一定百分比的用户。历史记录较短的用户通常会根据项目受欢迎程度而不是用户的个人需求或需要来显示

53

Page 58: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN 元数据

名称 描述模式。删除它们可以在训练模型时更多地关注数据中的基础模式。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.0

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

max_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最大百分位数。历史记录长度 是有关用户的数据总量。使用max_user_history_length_percentile 排除具有较长历史记录长度的一定百分比的用户,因为这些用户的数据往往包含噪音。例如,机器人可能有很长的自动交互列表。删除这些用户可限制训练中的噪音。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.99

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

HRNN 示例笔记本以下 Jupyter 笔记本显示如何使用 HRNN 配方:

• 有关演示如何将 HRNN 与保留集一起使用的示例笔记本,请参阅带有保留集时序评估的 AmazonPersonalize。

• 有关演示如何将 HRNN 与 PutEvents API 一起使用的示例笔记本,请参阅将 PutEvents API 与 AmazonPersonalize 结合使用。

HRNN 元数据配方HRNN 元数据配方可预测用户将与之交互的项目。它与具有从上下文、用户和项目元数据派生的附加功能(分别来自交互、用户和项目数据集)的 HRNN (p. 52) 配方相似。当有高质量的元数据可用时,HRNN元数据可提供高于非元数据模型的准确性。使用该配方可能需要更长的训练时间。

54

Page 59: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN 元数据

HRNN 元数据配方具有以下属性:

• 名称 – aws-hrnn-metadata• 配方 Amazon 资源名称 (ARN) – arn:aws:personalize:::recipe/aws-hrnn-metadata• 算法 ARN – arn:aws:personalize:::algorithm/aws-hrnn-metadata• 特征转换 ARN – arn:aws:personalize:::feature-transformation/featurize_metadata• 配方类型 – USER_PERSONALIZATION

下表描述 HRNN 元数据配方的超参数。超参数 是一个算法参数,您可以调整该参数以提高模型性能。算法超参数控制模型的执行方式。特征化超参数控制如何筛选训练中使用的数据。为超参数选择最佳值的过程称为超参数优化 (HPO)。有关更多信息,请参阅 超级参数和 HPO (p. 67)。

该表还为每个超参数提供以下信息:

• 范围:[上界, 下界]• 值类型:Integer、Continuous(浮点数)、Categorical(布尔值、列表、字符串)• 可调 HPO:该参数是否可以参与超级参数优化 (HPO)?

名称 描述

算法超参数

hidden_dimension 模型中使用的隐藏变量的数量。隐藏变量 重新创建用户的购买历史记录和项目统计数据来生成排名分数。当交互数据集包含更复杂的模式时,请指定更多数量的隐藏维度。使用更多隐藏维度需要更大的数据集和更多的处理时间。要确定最佳值,请使用 HPO。要使用 HPO,当您调用 CreateSolution (p. 123)和 CreateSolutionVersion (p. 128) 操作时,请将performHPO 设置为 true。

默认值:43

范围:[32, 256]

值类型:整数

HPO 可调:是

bptt 确定是否使用基于时间的反向传播技术。反向传播 是一种在基于递归神经网络的算法中更新权重的技术。将 bptt 用于长期积分以将延迟奖励与早期事件联系起来。例如,延迟奖励可以是几次点击后进行的购买。早期事件可以是初始点击。即使在相同的事件类型(例如点击)中,最好考虑长期影响并最大化总奖励。要考虑长期效果,请使用较大的bptt 值。使用较大的 bptt 值需要更大的数据集和更多的处理时间。

默认值:32

范围:[2, 32]

值类型:整数

HPO 可调:是

55

Page 60: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN 元数据

名称 描述

recency_mask 确定模型是否应考虑交互数据集中的最新流行趋势。最新流行趋势可能包括交互事件的基本模式的突然变化。要训练一个使最近事件具有更高权重的模型,请将 recency_mask设置为 true。要训练一个使所有过往交互占相同权重的模型,请将 recency_mask 设置为 false。要使用相等权重获得好的建议,您可能需要较大的训练数据集。

默认值:True

范围:True 或 False

值类型:布尔值

HPO 可调:是

特征化超参数

min_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最小百分位数。历史记录长度 是有关用户的数据总量。使用min_user_history_length_percentile 排除历史记录长度较短的一定百分比的用户。历史记录较短的用户通常会根据项目受欢迎程度而不是用户的个人需求或需要来显示模式。删除它们可以在训练模型时更多地关注数据中的基础模式。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.0

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

56

Page 61: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN-Coldstart

名称 描述

max_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最大百分位数。历史记录长度 是有关用户的数据总量。使用max_user_history_length_percentile 排除具有较长历史记录长度的一定百分比的用户,因为这些用户的数据往往包含噪音。例如,机器人可能有很长的自动交互列表。删除这些用户可限制训练中的噪音。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.99

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

HRNN 冷启动配方当您经常添加新项目和交互并希望立即获得有关这些项目的推荐时,可以使用 HRNN 冷启动配方来预测用户将与之交互的项目。HRNN 冷启动配方类似于 HRNN 元数据 (p. 54)配方,但它允许您获取有关新项目的推荐。

此外,当您由于最近的流行趋势或由于交互可能极不寻常并且在训练中引入噪音而希望从训练项目中排除具有长交互列表的项目时,也可以使用 HRNN 冷启动配方。使用 HRNN 冷启动,您可以筛选掉相关性较弱的项目以创建用于训练的子集。该项目子集称为冷项目,是在交互数据集中具有相关交互事件的项目。如果项目符合以下条件,则该项目被视为冷项目:

• 交互数量少于指定的最大交互数量。您在配方的 cold_start_max_interactions 超参数中指定此值。

• 相对持续时间短于最大持续时间。您在配方的 cold_start_max_duration 超参数中指定此值。

要减少冷项目的数量,请为 cold_start_max_interactions 或 cold_start_max_duration设置较低的值。要增加冷项目的数量,请为 cold_start_max_interactions 或cold_start_max_duration 设置较大的值。

HRNN-Coldstart 具有以下冷项目限制:

• Maximum cold start items:80,000• Minimum cold start items:100

如果冷项目的数量超出此范围,则尝试创建解决方案将失败。

HRNN-Coldstart 配方具有以下属性:

• 名称 – aws-hrnn-coldstart• 配方 Amazon 资源名称 (ARN) – arn:aws:personalize:::recipe/aws-hrnn-coldstart• 算法 ARN – arn:aws:personalize:::algorithm/aws-hrnn-coldstart

57

Page 62: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN-Coldstart

• 功能转换 ARN – arn:aws:personalize:::feature-transformation/featurize_coldstart• 配方类型 – USER_PERSONALIZATION

有关更多信息,请参阅 使用预定义配方 (p. 50)。

下表描述 HRNN-Coldstart 配方的超参数。超参数 是一个算法参数,您可以调整该参数以提高模型性能。算法超参数控制模型的执行方式。特征化超参数控制如何筛选训练中使用的数据。为超参数选择最佳值的过程称为超参数优化 (HPO)。有关更多信息,请参阅 超级参数和 HPO (p. 67)。

该表还为每个超参数提供以下信息:

• 范围:[上界, 下界]• 值类型:Integer、Continuous(浮点数)、Categorical(布尔值、列表、字符串)• 可调 HPO:该参数是否可以参与 HPO?

名称 描述

算法超参数

hidden_dimension 模型中使用的隐藏变量的数量。隐藏变量 重新创建用户的购买历史记录和项目统计数据来生成排名分数。当交互数据集包含更复杂的模式时,请指定更多数量的隐藏维度。使用更多隐藏维度需要更大的数据集和更多的处理时间。要确定最佳值,请使用 HPO。要使用 HPO,当您调用 CreateSolution (p. 123)和 CreateSolutionVersion (p. 128) 操作时,请将performHPO 设置为 true。

默认值:149

范围:[32, 256]

值类型:整数

HPO 可调:是

bptt 确定是否使用基于时间的反向传播技术。反向传播 是一种在基于递归神经网络的算法中更新权重的技术。将 bptt 用于长期积分以将延迟奖励与早期事件联系起来。例如,延迟奖励可以是几次点击后进行的购买。早期事件可以是初始点击。即使在相同的事件类型(例如点击)中,最好考虑长期影响并最大化总奖励。要考虑长期效果,请使用较大的bptt 值。使用较大的 bptt 值需要更大的数据集和更多的处理时间。

默认值:32

范围:[2, 32]

值类型:整数

HPO 可调:是

recency_mask 确定模型是否应考虑交互数据集中的最新流行趋势。最新流行趋势可能包括交互事件的基本模式的突然变化。要训练一个使最近事件具有更高权重的模型,请将 recency_mask设置为 true。要训练一个使所有过往交互占相同权重的模

58

Page 63: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南HRNN-Coldstart

名称 描述型,请将 recency_mask 设置为 false。要使用相等权重获得好的建议,您可能需要较大的训练数据集。

默认值:True

范围:True 或 False

值类型:布尔值

HPO 可调:是

特征化超参数

cold_start_max_interactions 项目可能必须被视为冷项目的最大用户-项目交互次数。

默认值:15

范围:正整数

值类型:整数

HPO 可调:否

cold_start_max_duration 用户-项目交互被视为冷启动项目的相对于起点的最大持续时间(以天为单位)。要设置用户-项目交互的起点,请设置 cold_start_relative_from 超参数。

默认值:5.0

范围:正浮点数

值类型:浮点数

HPO 可调:否

cold_start_relative_from 确定 HRNN 冷启动配方计算cold_start_max_duration 的起点。要从当前时间计算,请选择 currentTime。

要从交互数据集中最新项目的时间戳计算cold_start_max_duration,请选择 latestItem。如果您经常添加新项目,该设置将非常有用。

默认值:latestItem

范围:currentTime、latestItem

值类型:字符串

HPO 可调:否

59

Page 64: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南热门程度-计数

名称 描述

min_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最小百分位数。历史记录长度 是有关用户的数据总量。使用min_user_history_length_percentile 排除历史记录长度较短的一定百分比的用户。历史记录较短的用户通常会根据项目受欢迎程度而不是用户的个人需求或需要来显示模式。删除它们可以在训练模型时更多地关注数据中的基础模式。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.0

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

max_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最大百分位数。历史记录长度 是有关用户的数据总量。使用max_user_history_length_percentile 排除具有较长历史记录长度的一定百分比的用户,因为这些用户的数据往往包含噪音。例如,机器人可能有很长的自动交互列表。删除这些用户可限制训练中的噪音。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.99

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

HRNN-Coldstart 示例笔记本有关演示如何使用 HRNN-Coldstart 配方的 Jupyter 示例笔记本,请参阅 Amazon Personalize Coldstart 演示。

热门程度-计数配方热门程度-计数返回数据集中最热门的项目。热门项目由其在数据集中出现的次数定义。配方为所有用户返回相同的热门项目。相对于其他配方,热门程度-计数是一个好起点。

60

Page 65: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南个性化-排名

此预定义配方具有以下属性:

• 名称 – aws-popularity-count• 配方 ARN – arn:aws:personalize:::recipe/aws-popularity-count• 算法 ARN – arn:aws:personalize:::algorithm/aws-popularity-count• 功能转换 ARN – arn:aws:personalize:::feature-transformation/sims• 配方类型 – USER_PERSONALIZATION

热门程度-计数没有公开的超参数。

个性化-排名配方个性化排名配方可生成个性化排名。个性化排名 是为特定用户重新排名的推荐项目的列表。该配方具有以下属性:

• 名称 – aws-personalized-ranking• 配方 Amazon 资源名称 (ARN) – arn:aws:personalize:::recipe/aws-personalized-ranking• 算法 ARN – arn:aws:personalize:::algorithm/aws-personalized-ranking• 功能转换 ARN – arn:aws:personalize:::feature-transformation/JSON-percentile-filtering

• 配方类型 – PERSONALIZED_RANKING

下表描述了个性化排名配方的超参数。超参数 是一个算法参数,您可以调整该参数以提高模型性能。算法超参数控制模型的执行方式。特征化超参数控制如何筛选训练中使用的数据。为超参数选择最佳值的过程称为超参数优化 (HPO)。有关更多信息,请参阅 超级参数和 HPO (p. 67)。

该表还为每个超参数提供以下信息:

• 范围:[上界, 下界]• 值类型:Integer、Continuous(浮点数)、Categorical(布尔值、列表、字符串)• 可调 HPO:该参数是否可以参与超级参数优化 (HPO)?

名称 描述

算法超参数

hidden_dimension 模型中使用的隐藏变量的数量。隐藏变量 重新创建用户的购买历史记录和项目统计数据来生成排名分数。当交互数据集包含更复杂的模式时,请指定更多数量的隐藏维度。使用更多隐藏维度需要更大的数据集和更多的处理时间。要确定最佳值,请使用 HPO。要使用 HPO,当您调用 CreateSolution (p. 123)和 CreateSolutionVersion (p. 128) 操作时,请将performHPO 设置为 true。

默认值:149

范围:[32, 256]

值类型:整数

HPO 可调:是

61

Page 66: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南个性化-排名

名称 描述

bptt 确定是否使用基于时间的反向传播技术。反向传播 是一种在基于递归神经网络的算法中更新权重的技术。将 bptt 用于长期积分以将延迟奖励与早期事件联系起来。例如,延迟奖励可以是几次点击后进行的购买。早期事件可以是初始点击。即使在相同的事件类型(例如点击)中,最好考虑长期影响并最大化总奖励。要考虑长期效果,请使用较大的bptt 值。使用较大的 bptt 值需要更大的数据集和更多的处理时间。

默认值:32

范围:[2, 32]

值类型:整数

HPO 可调:是

recency_mask 确定模型是否应考虑交互数据集中的最新流行趋势。最新流行趋势可能包括交互事件的基本模式的突然变化。要训练一个使最近事件具有更高权重的模型,请将 recency_mask设置为 true。要训练一个使所有过往交互占相同权重的模型,请将 recency_mask 设置为 false。要使用相等权重获得好的建议,您可能需要较大的训练数据集。

默认值:True

范围:True 或 False

值类型:布尔值

HPO 可调:是

特征化超参数

min_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最小百分位数。历史记录长度 是有关用户的数据总量。使用min_user_history_length_percentile 排除历史记录长度较短的一定百分比的用户。历史记录较短的用户通常会根据项目受欢迎程度而不是用户的个人需求或需要来显示模式。删除它们可以在训练模型时更多地关注数据中的基础模式。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.0

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

62

Page 67: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南SIMS

名称 描述

max_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最大百分位数。历史记录长度 是有关用户的数据总量。使用max_user_history_length_percentile 排除具有较长历史记录长度的一定百分比的用户,因为这些用户的数据往往包含噪音。例如,机器人可能有很长的自动交互列表。删除这些用户可限制训练中的噪音。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,设置 min__user_history_length_percentileto 0.05 和 max_user_history_length_percentileto 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.99

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

SIMS 配方项目与项目相似性 (SIMS) 配方基于协作筛选的概念。SIMS 模型利用用户-项目交互数据来推荐与给定项目相似的项目。如果一个项目没有足够的用户行为数据,此配方会推荐热门项目。

此预定义配方具有以下属性:

• 名称 – aws-sims• 配方 Amazon 资源名称 (ARN) – arn:aws:personalize:::recipe/aws-sims• 算法 ARN – arn:aws:personalize:::algorithm/aws-sims• 特征转换 ARN – arn:aws:personalize:::feature-transformation/sims• 配方类型 – RELATED_ITEMS

下表描述 SIMS 配方的超参数。超参数 是一个算法参数,您可以调整该参数以提高模型性能。算法超参数控制模型的执行方式。特征化超参数控制如何筛选训练中使用的数据。为超参数选择最佳值的过程称为超参数优化 (HPO)。有关更多信息,请参阅 超级参数和 HPO (p. 67)。

该表还为每个超参数提供以下信息:

• 范围:[上界, 下界]• 值类型:Integer、Continuous(浮点数)、Categorical(布尔值、列表、字符串)• 可调 HPO:该参数是否可以参与超级参数优化 (HPO)?

名称 描述

算法超参数

popularity_discount_factor 计算相似度时会影响流行度和相关性之间的平衡。如果您计算与特定项目的相似性,则值 0 会将最受欢迎的项目显示为建议,无论其相关性如何。值为 1 使与特定项目具有共同交

63

Page 68: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南SIMS

名称 描述互(共享交互)的大多数项目显示为推荐,而不管其受欢迎程度如何。使用任一极值都可能会创建一个过长的推荐项目列表。对于大多数情况,0.5 左右的值效果最好。

缩放细节凹凸法线强度。

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:是

min_cointeraction_count 计算一对项目之间的相似性所需的最小共同交互次数。例如,值 3 表示您需要三个或更多与这两个项目进行交互的用户以供算法计算其相似性。

默认值:3

范围:[0, 10]

值类型:整数

HPO 可调:是

特征化超参数

min_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最小百分位数。历史记录长度 是用户的可用数据总量。使用min_user_history_length_percentile 排除历史记录长度较短的一定百分比的用户。历史记录较短的用户通常会根据项目受欢迎程度而不是用户的个人需求或需要来显示模式。删除它们可以在训练模型时更多地关注数据中的基础模式。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

默认值:0.005

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

64

Page 69: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南SIMS

名称 描述

max_user_history_length_percentile要包含在模型训练中的用户历史记录长度的最大百分位数。历史记录长度是用户的可用数据总量。使用max_user_history_length_percentile 排除历史记录长度较长的一定百分比的用户。具有较长历史记录的用户往往包含噪音。例如,机器人可能有很长的自动交互列表。删除这些用户可限制训练中的噪音。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数用户,但会删除边缘案例。

例如,min_hist_length_percentile = 0.05 和max_hist_length_percentile = 0.95 将包括除那些历史记录长度在最低或最高 5% 内的用户之外的所有用户。

默认值:0.995

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

min_item_interaction_count_percentile要包含在模型训练中的项目交互计数的最小百分位数。使用min_item_interaction_count_percentile 排除交互历史记录较短的百分比的项目。历史记录较短的项目通常是新项目。删除它们可以在训练模型时更多地关注具有已知历史记录的项目。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数项目,但会删除边缘案例。

默认值:0.01

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

65

Page 70: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南覆盖默认配方参数

名称 描述

max_item_interaction_count_percentile要包含在模型训练中的项目交互计数的最大百分位数。使用max_item_interaction_count_percentile 排除交互历史记录较长的百分比的项目。具有较长的历史记录的项目往往较旧,可能已过时。例如,已绝版的电影发行版本。删除这些项目可以专注于相关性更高的项目。使用直方图或类似工具查看用户历史记录长度后,请选择适当的值。我们建议您设置一个值,该值将保留大多数项目,但会删除边缘案例。

例如,min_item_interaction_count_percentile= 0.05 和max_item_interaction_count_percentile =0.95 将包括除交互计数在最低或最高 5% 内的项目之外的所有项目。

默认值:0.9

范围:[0.0, 1.0]

值类型:浮点数

HPO 可调:否

SIMS 示例笔记本有关演示如何使用 SIMS 配方的 Jupyter 示例笔记本,请参阅查找类似项目 + HPO。

覆盖默认配方参数通过调用 CreateSolution (p. 123) API 创建解决方案。显示 CreateSolution 请求的精简版本,重点突出 solutionConfig 对象。您使用 solutionConfig 来覆盖配方的默认参数。 当 performAutoML为 true 时,将忽略 solutionConfig 对象的所有参数,autoMLConfig 除外。以下部分讨论了solutionConfig 子对象。

{ "name": "string", "performAutoML": boolean, "recipeArn": "string", "performHPO": boolean, "eventType": "string", "solutionConfig": { "autoMLConfig": { "metricName": "string", "recipeList": [ "string" ] }, "eventValueThreshold": "string", "featureTransformationParameters": { "string" : "string" }, "algorithmHyperParameters": { "string" : "string" }, "hpoConfig": { "algorithmHyperParameterRanges": { ...

66

Page 71: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南超级参数和 HPO

}, "hpoObjective": { "metricName": "string", "metricRegex": "string", "type": "string" }, "hpoResourceConfig": { "maxNumberOfTrainingJobs": "string", "maxParallelTrainingJobs": "string" } }, },}

主题• 超级参数和 HPO (p. 67)

超级参数和 HPO超级参数用于优化经过训练的模型,在训练开始之前设置。这与模型参数相反,后者的值在训练过程中确定。

超参数是使用 algorithmHyperParameters 键指定的,该键是传递到 CreateSolution (p. 123) 操作的SolutionConfig (p. 268) 对象的一部分。

使用不同超级参数的不同配方。有关可用的超级参数,请参阅使用预定义配方 (p. 50)中的各个配方。

超参数优化 (HPO) 或调整是针对特定学习目标选择最佳超参数的任务。最佳超级参数是通过运行使用来自指定可能性范围的不同值的很多训练任务确定的。默认情况下,Amazon Personalize 不执行 HPO。要使用HPO,请将 performHPO 设置为 true,并包含 hpoConfig 对象。

超参数可以是分类值、连续值或整数值。hpoConfig 对象具有与所有这些类型对应的键,您可以在其中指定超级参数及其范围。请注意,并非所有超级参数都可以调整(请参阅配方表)。

以下是使用 HRNN (p. 52) 配方的 CreateSolution 请求的部分示例。

{ "performAutoML": false, "recipeArn": "arn:aws:personalize:::recipe/aws-hrnn", "performHPO": true, "solutionConfig": { "algorithmHyperParameters": { "hidden_dimension": "55" }, "hpoConfig": { "algorithmHyperParameterRanges": { "categoricalHyperParameterRanges": [ { "name": "recency_mask", "values": [ "true", "false" ] } ], "integerHyperParameterRanges": [ { "name": "bptt", "minValue": 20, "maxValue": 40 } ] }, "hpoObjective": {

67

Page 72: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南超级参数和 HPO

"metricName": "precision_at_25", "metricRegex": "string", "type": "Maximize" }, "hpoResourceConfig": { "maxNumberOfTrainingJobs": "4", "maxParallelTrainingJobs": "2" } } }}

训练完成后,您可以通过调用 the section called “DescribeSolutionVersion” (p. 166) 操作来查看最佳性能模型的超参数。以下示例显示了压缩的 DescribeSolutionVersion 输出,其中在 tunedHPOParams 对象中显示了经过优化的超参数。

{ "solutionVersion":{ "creationDateTime":1562191944.745, "datasetGroupArn":"arn:aws:personalize:us-west-2:000000000000:dataset-group/hpo", "lastUpdatedDateTime":1562194465.075, "performAutoML":false, "performHPO":true, "recipeArn":"arn:aws:personalize:::recipe/aws-hrnn", "solutionArn":"arn:aws:personalize:us-west-2:000000000000:solution/hpo", "solutionVersionArn":"arn:aws:personalize:us-west-2:000000000000:solution/hpo/5a515609", "status":"ACTIVE", "tunedHPOParams":{ "algorithmHyperParameters":{ "hidden_dimension":"58", "recency_mask":"false" } } }}

有关更多信息,请参阅自动模型优化。

68

Page 73: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南指标

评估解决方案版本Amazon Personalize 在创建解决方案版本时会生成很多指标。利用这些指标,您在创建市场活动并提供推荐之前可以评估解决方案版本的性能。指标可让您查看修改解决方案的超级参数的效果。您还可以比较使用相同的训练数据但使用不同的配方创建的各个解决方案的指标。

为了获取性能指标,Amazon Personalize 会随机选择 90% 的用户及其相关交互作为训练数据,并选择另外10% 作为测试数据,从而拆分输入交互数据。随后将使用训练数据创建解决方案版本。然后,解决方案版本会将每个用户的测试数据中最早的 90% 作为输入,并将生成的建议与最近 10% 的测试数据给出的真实交互进行比较。

对于用户个性化,建议对数据运行多个配方以确定最佳解决方案。作为基准,请运行 热门程度-计数 (p. 60)配方,该配方推荐了前 K 个最热门的项目。

Important

为了使 Amazon Personalize 生成解决方案版本指标,您的输入数据集组中必须至少包含 10 个数据点。

指标您通过调用 GetSolutionMetrics (p. 169) 操作为特定解决方案版本检索指标。

使用 AWS Python 开发工具包检索指标

1. 创建解决方案版本。有关更多信息,请参阅 创建解决方案 (p. 48)。2. 使用以下代码来检索指标。

import boto3

personalize = boto3.client('personalize')

response = personalize.get_solution_metrics( solutionVersionArn = 'solution version arn')

print(response['metrics'])

下面是来自使用带有默认解决方案配置的 HRNN (p. 52) 配方创建的解决方案版本的输出示例。

{ "solutionVersionArn": "arn:aws:personalize:us-west-2:acct-id:solution/MovieSolution/<version-id>", "metrics": { "coverage": 0.27, "mean_reciprocal_rank_at_25": 0.0379, "normalized_discounted_cumulative_gain_at_5": 0.0405, "normalized_discounted_cumulative_gain_at_10": 0.0513, "normalized_discounted_cumulative_gain_at_25": 0.0828, "precision_at_5": 0.0136, "precision_at_10": 0.0102, "precision_at_25": 0.0091 }

69

Page 74: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南示例

}

上述指标在下面使用以下术语进行描述:

• 相关推荐 是指与特定用户的测试数据中的值匹配的推荐。• 排名 是指推荐项在推荐列表中的位置。位置 1(列表的顶部)被假定为与用户最相关。• 查询 是指 GetRecommendations (p. 204) 调用的内部等效项。

对于每个指标,数字越大越好。

覆盖

来自所有查询中的唯一推荐项占训练数据中的唯一项的总数的比例(包括项目和交互数据集)。mean_reciprocal_rank_at_25

针对所有查询的前 25 个推荐中第一个相关推荐的倒数排名的平均值。

如果您对单个排名最高的推荐感兴趣,那么此指标是合适的。normalized_discounted_cumulative_gain_at_K

折扣收益假定推荐列表中排名较低的推荐与排名较高的推荐相比相关性更低。因此,每个推荐被折扣一倍(给定较低的权重),具体取决于其位置。为了在 K 处产生累积折扣增益 (DCG),前 K 个推荐中的每个相关折扣推荐被相加。归一化折扣累计增益 (NDCG) 是 DCG 除以理想 DCG,使得 NDCG 在 0-1 之间。(在理想 DCG 中,前 K 个推荐将按相关性进行排序。)

Amazon Personalize 使用了加权系数 1/log(1 + position),其中列表的顶部是位置 1。

此指标奖励出现在列表顶部附近的相关项目,因为列表顶部通常会引起更多关注。precision_at_K

前 K 个推荐中的相关推荐数除以 K。

此指标奖励相关项目的精准推荐。

示例下面是一个简单的示例,其中,为了生成指标,解决方案版本将为特定用户生成一个推荐列表。第二个和第五个推荐与此用户的测试数据中的记录匹配。这些是相关的推荐。如果将 K 设置为 5,将为该用户生成以下指标。

reciprocal_rank

计算:1/2

结果:0.5000normalized_discounted_cumulative_gain_at_5

计算:(1/log(1 + 2) + 1/log(1 + 5)) / (1/log(1 + 1) + 1/log(1 + 2))

结果:0.6241precision_at_5

计算:2/5

结果:0.4000

70

Page 75: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南更多信息

既然您已评估您的解决方案版本,请通过部署最佳解决方案版本创建一个市场活动。有关更多信息,请参阅创建活动 (p. 72)。

更多信息有关演示如何根据保留数据检索指标的 Jupyter 示例笔记本,请参阅带有保留集时序评估的 Personalize。

71

Page 76: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

创建活动活动用于对您的用户进行推荐。通过部署解决方案版本来创建市场活动。有关使用 AWS CLI 的示例,请参阅步骤 3:创建活动(部署解决方案) (p. 29)。

要使用开发工具包创建活动,请调用 CreateCampaign (p. 106) API 并传递以下内容:

• 活动的名称。• 要部署的解决方案版本的 Amazon 资源名称 (ARN)。• Amazon Personalize 将支持的每秒最小预置交易数 (minProvisionedTPS)。有关minProvisionedTPS 的更多信息,请参阅 CreateCampaign API。

使用 AWS Python 开发工具包创建活动

1. 创建要部署的解决方案版本。有关更多信息,请参阅 创建解决方案 (p. 48)。2. 使用以下代码创建活动。

import boto3

personalize = boto3.client('personalize')

response = personalize.create_campaign( name = 'campaign name', solutionVersionArn = 'solution version arn', minProvisionedTPS = 10)

arn = response['campaignArn']

description = personalize.describe_campaign(campaignArn = arn)['campaign']print('Name: ' + description['name'])print('ARN: ' + description['campaignArn'])print('Status: ' + description['status'])

活动在其状态变为“活动”之前不可用。要获取当前状态,请调用 DescribeCampaign (p. 147) 并检查status 字段是否为 ACTIVE。

Amazon Personalize 提供用于管理活动的操作(如 ListCampaigns (p. 174))以列出您创建的活动。您可以通过调用 DeleteCampaign (p. 131) 来删除活动。如果您删除一个市场活动,不会删除属于该市场活动的一部分的解决方案版本。

在创建您的市场活动后,请使用它来进行推荐。有关更多信息,请参阅 获得推荐 (p. 73)。

72

Page 77: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南推荐评分的工作原理

获得推荐创建市场活动之后,您可在应用程序中使用它获得推荐。以下主题介绍了如何以及在何时使用每种推荐类型。

主题• 推荐评分的工作原理 (p. 73)• 获取实时推荐 (p. 73)• 获取批量推荐 (p. 75)

推荐评分的工作原理为提出推荐,Amazon Personalize 根据用户的交互数据和元数据为项目数据集中的项目生成分值。这些分数表示 Amazon Personalize 对于用户接下来将选择哪个项目的相对确定性。分数越高,意味着确定性越大。

计算分数的公式取决于推荐使用案例和用于训练模型的方法。您可以在 Amazon Personalize 控制台中或使用 Amazon Personalize 运行时 API 查看项目分数。有关如何计算分数及其含义的更多信息,请参阅获取实时推荐 (p. 73)和获取批量推荐 (p. 75)。

获取实时推荐您可以通过广告活动从 Amazon Personalize 获取实时推荐。例如,假设您有一个旨在提供电影推荐的活动。您可以使用以下操作向已登录您的应用程序或网站的用户提供实时电影推荐。有关使用 AWS CLI 的示例,请参阅步骤 4:获得推荐 (p. 30)。

主题• GetRecommendations (p. 73)• 获取个性化排名 (p. 74)

GetRecommendations要获得推荐,请调用 GetRecommendations (p. 204) API。提供用户 ID 或项目ID,具体取决于用于创建市场活动所基于的解决方案的配方类型。

要获取上下文推荐,您还可以包含有关您的用户的上下文元数据。例如,您可以包含有关用户当前位置或设备(台式机、移动设备、平板电脑)的信息,使得 Amazon Personalize 能够根据该用户之前的情境行为获取建议。任何元数据上下文字段都必须包含在活动的用户项交互数据集的架构中。

Note

必须已使用 USER_PERSONALIZATION 或 RELATED_ITEMS 类型的配方创建支持市场活动的解决方案。有关更多信息,请参阅 使用预定义配方 (p. 50)。

评分的工作原理

基于 USER_PERSONALIZATION 方法的模型对项目数据集中的所有项目进行相对于彼此的评分,其分数范围为 0 到 1(包含这两者),使得所有分数的总和等于 1。例如,如果您要获取用户的影片推荐,并且项目数据集中有三个电影,则其分数可能为 .6、.3、和 .1。同样,如果您的库存中有 1,000 部电影,则得分最高的电影的分数可能非常小(平均分数为.001),但由于评分是相对的,推荐仍然有效。

73

Page 78: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南获取个性化排名

在数学术语中,每个用户-项目对 (u, i) 的分数是根据以下公式计算的,其中“exp”是指数函数,w̅ u 和 wi/j 分别是用户和项目嵌入内容,希腊字母西格玛 (Σ) 表示项目数据集中所有项目的求和:

Note

SIMS 或基于流行计数的模型不显示分数。

使用 AWS Python 开发工具包获得推荐

使用以下代码可获得推荐。将 userId 的值更改为用于训练解决方案的数据中的用户 ID。将显示为用户推荐的项目的列表。

import boto3

personalizeRt = boto3.client('personalize-runtime')

response = personalizeRt.get_recommendations( campaignArn = 'Campaign ARN', userId = 'User ID')

print("Recommended items")for item in response['itemList']: print (item['itemId'])

使用以下代码,根据上下文元数据获取建议。将 context 键值对的值更改为用作您的训练数据的元数据字段的值。将显示为用户推荐的项目的列表。

import boto3

personalizeRt = boto3.client('personalize-runtime')

response = personalizeRt.get_recommendations( campaignArn = 'Campaign ARN', userId = 'User ID', context = { 'key': 'value' })

print("Recommended items")for item in response['itemList']: print (item['itemId'])

获取个性化排名个性化排名是为特定用户重新排名的推荐项目的列表。要获取个性化排名,请调用GetPersonalizedRanking (p. 202) API。

Note

必须已使用 PERSONALIZED_RANKING 类型的配方创建支持市场活动的解决方案。有关更多信息,请参阅 使用预定义配方 (p. 50)。

评分的工作原理

74

Page 79: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南获取批量推荐

与 GetRecommendations 操作返回的分数相似, GetPersonalizedRanking 分数总和为 1,但由于所考虑项目的列表比您的完整项目数据集小得多,因此推荐分数往往更高。

在数学上,GetPersonalizedRanking 的评分函数与 GetRecommendations 相同,但它只考虑输入项目。这意味着分数接近 1 的可能性更高,因为将分数进行划分的其他选择更少:

使用 AWS Python 开发工具包获得个性化排名

使用以下代码可获得个性化排名。将 userId 和 inputList 的值分别更改为用于训练解决方案的数据中的用户 ID 及项目 ID 列表。此时将显示排名推荐的列表。Amazon Personalize 会考虑用户最感兴趣的列表中的第一个项目。

import boto3

personalizeRt = boto3.client('personalize-runtime')

response = personalizeRt.get_personalized_ranking( campaignArn = "Campaign arn", userId = "UserID", inputList = ['ItemID1','ItemID2'])

print("Personalized Ranking")for item in response['personalizedRanking']: print (item['itemId'])

使用以下代码,根据上下文元数据获取个性化排名。将 context 键值对的值更改为训练数据中元数据字段的值。Amazon Personalize 会考虑用户最感兴趣的列表中的第一个项目。

import boto3

personalizeRt = boto3.client('personalize-runtime')

response = personalizeRt.get_personalized_ranking( campaignArn = "Campaign arn", userId = "UserID", inputList = ['ItemID1', 'ItemID2'], context = { 'key': 'value' })

print("Personalized Ranking")for item in response['personalizedRanking']: print(item['itemId'])

获取批量推荐使用异步批处理工作流程从不需要实时更新的大型数据集获取推荐。例如,您可以创建批处理推理作业,以获取电子邮件列表中所有用户的产品建议,或者获得库存中的物料与物料相似性 (SIMS) (p. 63)。要获取批处理建议,您可以通过调用 CreateBatchInferenceJob (p. 103) 创建批处理推理作业。

CreateBatchInferenceJob (p. 103) 使用选定的解决方案版本根据输入 JSON 文件中提供的数据提供建议。然后,结果将作为 JSON 文件返回到 Amazon S3 存储桶。以下选项卡列表包含格式正确的 JSON 输入和每种配方类型的输出摘录。

75

Page 80: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南获取批量推荐

评分的工作原理

批量推荐作业计算项目分数的方式与获取实时推荐 (p. 73)中所述相同,并且可以在批处理作业的输出JSON 文件中查看。只有使用 HRNN 和 Personalize-Ranking 方法训练的模型才能返回分数。

HRNN

Input

{"userId": "4638"}{"userId": "663"}{"userId": "3384"}...

Output

{"input":{"userId":"4638"}, "output": {"recommendedItems": ["296", "1", "260", "318"]}, {"scores": [0.0009785, 0.000976, 0.0008851]}}{"input":{"userId":"663"}, "output": {"recommendedItems": ["1393", "3793", "2701", "3826"]}, {"scores": [0.00008149, 0.00007025, 0.000652]}}{"input":{"userId":"3384"}, "output": {"recommendedItems": ["8368", "5989", "40815", "48780"]}, {"scores": [0.003015, 0.00154, 0.00142]}}...

热门程度-计数

Input

{}{"itemId": "105"}{"itemId": "41"}...

Output

{"input": {}, "output": {"recommendedItems": ["105", "106", "441"]}}{"input": {"itemId": "105"}, "output": {"recommendedItems": ["105", "106", "441"]}}{"input": {"itemId": "41"}, "output": {"recommendedItems": ["105", "106", "441"]}}...

个性化排名

Input

{"userId": "891", "itemList": ["27", "886", "101"]}{"userId": "445", "itemList": ["527", "55", "901"]}{"userId": "71", "itemList": ["27", "351", "101"]}...

Output

{"input": {"userId": "891", "itemList": ["27", "886", "101"]}, "output": {"recommendedItems": ["27", "101", "886"]}, {"scores": [0.48421, 0.28133, 0.23446]}}{"input": {"userId": "445", "itemList": ["527", "55", "901"]}, "output": {"recommendedItems": ["901", "527", "55"]}, {"scores": [0.46972, 0.31011, 0.22017]}}

76

Page 81: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南获取批处理建议(Amazon Personalize 控制台)

{"input": {"userId": "71", "itemList": ["29", "351", "199"]}, "output": {"recommendedItems": ["351", "29", "199"]}, {"scores": [0.68937, 0.24829, 0.06232]}}...

SIMS

Input

{"itemId": "105"}{"itemId": "106"}{"itemId": "441"}...

Output

{"input": {"itemId": "105"}, "output": {"recommendedItems": ["106", "107", "49"]}, }{"input": {"itemId": "106"}, "output": {"recommendedItems": ["105", "107", "49"]}}{"input": {"itemId": "441"}, "output": {"recommendedItems": ["2", "442", "435"]}}...

为了获取批处理建议,调用 CreateBatchInferenceJob (p. 103) 操作的 IAM 用户角色必须分别对输入和输出 Amazon S3 存储桶具有读取和写入权限。有关存储桶权限的更多信息,请参阅 Amazon Simple StorageService (S3) 开发人员指南 中的用户策略示例。

您可以使用以下任一工具执行批处理推理操作:

• Amazon Personalize 控制台 (p. 77)• AWS CLI (p. 78)• AWS 开发工具包 (p. 79)

获取批处理建议(Amazon Personalize 控制台)以下过程概述了使用 Amazon Personalize 控制台的批处理推理工作流程。此过程假定您已经创建了一个格式正确的解决方案,以便在数据集上执行所需的批处理作业。

1. 通过 https://console.aws.amazon.com/personalize/home 打开 Amazon Personalize 控制台,并登录您的账户。

2. 在导航窗格中选择 Batch inference jobs (批处理推理作业),然后选择 Create batch inference job (创建批处理推理作业)。

3. 在 Batch inference job details (批处理推理作业详细信息) 中,在 Batch inference job name (批处理推理作业名称) 中,指定批处理推理作业的名称。

4. 对于 IAM service role (IAM 服务角色),选择对输入和输出 Amazon S3 存储桶分别具有读取和写入访问权限的 Amazon Personalize IAM 服务角色。

5. 对于 Solution (解决方案),选择要用于生成建议的解决方案。此解决方案配方必须与输入数据的格式匹配。

6. 在 Input data configuration (输入数据配置) 中,指定指向输入文件的 Amazon S3 路径。在 Output dataconfiguration (输出数据配置) 中,指定指向输出 Amazon S3 存储桶的路径。

7. 选择 Create batch inference job (创建批处理推理作业)。此时将开始创建批处理推理作业,Batchinference jobs (批处理推理作业) 页面将显示,并显示 Batch inference job detail (批处理推理作业详细信息) 部分。

您的屏幕应类似于以下内容:

77

Page 82: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南获取批处理建议 (AWS CLI)

Note

创建批处理推理作业需要一定的时间。8. 当批处理推理作业的状态更改为 Active (活动) 时,您可以从指定的输出 Amazon S3 存储桶中检索作业

的输出。输出文件的名称将采用 input-name.out 格式。

获取批处理建议 (AWS CLI)以下是使用 AWS CLI 的批处理推理工作流程的示例。名为 batch.json 的 JSON 文件作为输入传递,输出文件 batch.json.out 返回到 Amazon S3 存储桶。

aws personalize create-batch-inference-job --job-name batchTest \ --solution-version-arn arn:aws:personalize:us-west-2:012345678901:solution/batch-test-solution-version/1234abcd \ --job-input s3DataSource={path=s3://personalize/batch/input/input.json} \ --job-output s3DataDestination={path=s3://personalize/batch/output/} \ --role-arn arn:aws:iam::012345678901:role/import-export-role { "batchInferenceJobArn": "arn:aws:personalize:us-west-2:012345678901:batch-inference-job/batchTest"}

创建批处理推理作业后,您可以通过 DescribeBatchInferenceJob (p. 145) 操作进一步检查该作业。

aws personalize describe-batch-inference-job --batch-inference-job-arn arn:aws:personalize:us-west-2:012345678901:batch-inference-job/batchTest

{ "jobName": "batchTest", "batchInferenceJobArn": "arn:aws:personalize:us-west-2:012345678901:batch-inference-job/batchTest", "solutionVersionArn": "arn:aws:personalize:us-west-2:012345678901:solution/batch-test-solution-version/1234abcd", "jobInput": { "s3DataSource": { "path": "s3://personalize/batch/input/batch.json" } }, "jobOutput": {

78

Page 83: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南获取批处理建议(AWS Python 开发工具包)

"s3DataDestination": { "path": "s3://personalize/batch/output/" } }, "roleArn": "arn:aws:iam::012345678901:role/import-export-role", "status": "ACTIVE", "creationDateTime": 1542392161.837, "lastUpdateDateTime: 1542393013.377}

获取批处理建议(AWS Python 开发工具包)使用以下代码可以通过 AWS Python 开发工具包获取批处理建议。操作从 Amazon S3 存储桶读取输入JSON 文件,并将输出 JSON 文件 (input-file-name.out) 放入 Amazon S3 存储桶中。

Amazon Personalize 将响应文件中的第一个项目视为用户最感兴趣的项目。

import boto3

personalize_rec = boto3.client(service_name='personalize')

personalize_rec.create_batch_inference_job ( solutionVersionArn = "Solution version ARN", jobName = "Batch job name", roleArn = "IAM role ARN", jobInput = {"s3DataSource": {"path": S3 input path}}, jobOutput = {"s3DataDestination": {"path":S3 output path"}})

命令返回批处理作业的 ARN (batchRecommendationsJobArn)。

处理批处理作业可能需要一段时间才能完成。您可以通过调用 DescribeBatchInferenceJob (p. 145)和传递 batchRecommendationsJobArn 作为输入参数来检查作业的状态。还可以通过调用ListBatchInferenceJobs (p. 171) 以列出 AWS 环境中的所有 Amazon Personalize 批处理推理作业。

79

Page 84: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南数据保护

Amazon Personalize 中的安全性AWS 的云安全性的优先级最高。作为 AWS 客户,您将从专为满足大多数安全敏感型组织的要求而打造的数据中心和网络架构中受益。

安全性是 AWS 和您的共同责任。责任共担模型将其描述为云的安全性和云中的安全性:

• 云的安全性 – AWS 负责保护在 AWS 云中运行 AWS 服务的基础设施。AWS 还向您提供可安全使用的服务。作为 AWS 合规性计划的一部分,第三方审计人员将定期测试和验证安全性的有效性。要了解适用于Amazon Personalize 的合规性计划,请参阅合规性计划范围内的 AWS 服务。

• 云中的安全性 – 您的责任由您使用的 AWS 服务决定。您还需要对其他因素负责,包括您的数据的敏感性、您公司的要求以及适用的法律法规。

此文档将帮助您了解如何在使用 Amazon Personalize 时应用责任共担模型。以下主题说明如何配置Amazon Personalize 以实现您的安全性和合规性目标。您还将了解如何使用其他 AWS 服务来帮助您监控和保护 Amazon Personalize 资源。

主题• Amazon Personalize 中的数据保护 (p. 80)• 适用于 Amazon Personalize 的 Identity and Access Management (p. 81)• Amazon Personalize 中的日志记录和监控 (p. 90)• Amazon Personalize 的合规性验证 (p. 96)• Amazon Personalize 中的弹性 (p. 97)• Amazon Personalize 中的基础设施安全性 (p. 97)

Amazon Personalize 中的数据保护Amazon Personalize 符合 AWS 责任共担模式,此模式包含适用于数据保护的法规和准则。AWS 负责保护运行所有 AWS 服务的全球基础设施。AWS 保持对此基础设施上托管的数据的控制,包括用于处理客户内容和个人数据的安全配置控制。充当数据控制者或数据处理者的 AWS 客户和 APN 合作伙伴对他们在 AWS 云中放置的任何个人数据承担责任。

出于数据保护的目的,我们建议您保护 AWS 账户凭证并使用 AWS Identity and Access Management (IAM)设置单个用户账户,以便仅向每个用户提供履行其工作职责所需的权限。我们还建议您通过以下方式保护您的数据:

• 对每个账户使用 Multi-Factor Authentication (MFA)。• 使用 SSL/TLS 与 AWS 资源进行通信。

• 使用 AWS CloudTrail 设置 API 和用户活动日志记录。• 使用 AWS 加密解决方案以及 AWS 服务中的所有默认安全控制。• 使用高级托管安全服务(例如 Amazon Macie),它有助于发现和保护存储在 Amazon Simple Storage

Service (Amazon S3) 中的个人数据。

我们强烈建议您切勿将敏感的可识别信息(例如您客户的账号)放入自由格式字段(例如 Name (名称) 字段)。这包括使用控制台、API、AWS CLI 或 AWS 开发工具包处理 Amazon Personalize 或其他 AWS 服务时。您输入到 Amazon Personalize 或其他服务中的任何数据都可能被选取以包含在诊断日志中。当您向外部服务器提供 URL 时,请勿在 URL 中包含凭证信息来验证您对该服务器的请求。

80

Page 85: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南静态加密

有关数据保护的更多信息,请参阅 AWS 安全性博客上的 AWS 责任共担模型和 GDPR 博客文章。

静态加密Amazon Personalize 使用默认 Amazon S3 密钥 (SSE-S3) 对放入 S3 存储桶的 Amazon Personalize 数据进行服务器端加密。您也可以使用自己的某个 AWS Key Management Service (AWS KMS) 密钥。

传输中加密Amazon Personalize 将数据复制到您的账户,并在内部 AWS 系统中处理这些数据。默认情况下,AmazonPersonalize 结合使用 TLS 1.2 和 AWS 证书来加密传输中的数据。

密钥管理默认 Amazon S3 密钥由 AWS 托管。客户应负责管理由客户提供的任何 AWS Key Management Service(AWS KMS) 密钥。

适用于 Amazon Personalize 的 Identity and AccessManagement

AWS Identity and Access Management (IAM) 是一项 AWS 服务,可帮助管理员安全地控制对 AWS 资源的访问。IAM 管理员控制谁可以通过身份验证 (登录)和授权 (具有权限)以使用 Amazon Personalize 资源。IAM 是一项无需额外费用即可使用的 AWS 服务。

主题• 受众 (p. 81)• 使用身份进行身份验证 (p. 82)• 使用策略管理访问 (p. 83)• Amazon Personalize 如何与 IAM 协同工作 (p. 84)• Amazon Personalize 基于身份的策略示例 (p. 86)• 故障排除 Amazon Personalize 身份和访问 (p. 89)

受众如何使用 AWS Identity and Access Management (IAM) 因您可以在 Amazon Personalize 中执行的操作而异。

服务用户 – 如果您使用 Amazon Personalize 服务来完成工作,则您的管理员会为您提供所需的凭证和权限。当您使用更多 Amazon Personalize 功能来完成工作时,您可能需要额外权限。了解如何管理访问权限可帮助您向管理员请求适合的权限。如果您无法访问 Amazon Personalize 中的一项功能,请参阅故障排除Amazon Personalize 身份和访问 (p. 89)。

服务管理员 – 如果您在公司负责管理 Amazon Personalize 资源,则您可能具有 Amazon Personalize 的完全访问权限。您有责任确定您的员工应访问哪些 Amazon Personalize 功能和资源。然后,您必须向 IAM 管理员提交请求以更改您的服务用户的权限。检查此页上的信息,了解 IAM 的基本概念。要了解有关您的公司如何将 IAM 与 Amazon Personalize 搭配使用的更多信息,请参阅Amazon Personalize 如何与 IAM 协同工作 (p. 84)。

IAM 管理员 – 如果您是 IAM 管理员,您可能希望了解有关您可以如何编写策略以管理 Amazon Personalize访问权限的详细信息。要查看您可在 IAM 中使用的基于身份的 Amazon Personalize 示例策略,请参阅Amazon Personalize 基于身份的策略示例 (p. 86)。

81

Page 86: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南使用身份进行身份验证

使用身份进行身份验证身份验证是您使用身份凭证登录 AWS 的方法。有关使用 AWS 管理控制台登录的更多信息,请参阅 IAM 用户指南 中的 IAM 控制台和登录页面。

您必须以 AWS 账户根用户、IAM 用户身份或通过代入 IAM 角色进行身份验证(登录到 AWS)。您还可以使用公司的单一登录身份验证方法,甚至使用 Google 或 Facebook 登录。在这些案例中,您的管理员以前使用 IAM 角色设置了联合身份验证。在您使用来自其他公司的凭证访问 AWS 时,您间接地代入了角色。

要直接登录到 AWS 管理控制台,请使用您的密码和 根用户 电子邮件或 IAM 用户名。您可以使用 根用户 或IAM 用户访问密钥以编程方式访问 AWS。AWS 提供了开发工具包和命令行工具,可使用您的凭证对您的请求进行加密签名。如果您不使用 AWS 工具,则必须自行对请求签名。使用签名版本 4(用于对入站 API 请求进行验证的协议)完成此操作。有关验证请求的更多信息,请参阅 AWS General Reference 中的签名版本4 签名流程。

无论使用何种身份验证方法,您可能还需要提供其他安全信息。例如,AWS 建议您使用多重身份验证 (MFA)来提高账户的安全性。要了解更多信息,请参阅 IAM 用户指南 中的在 AWS 中使用多重身份验证 (MFA)。

AWS 账户根用户当您首次创建 AWS 账户时,最初使用的是一个对账户中所有 AWS 服务和资源有完全访问权限的单点登录身份。此身份称为 AWS 账户 根用户,可使用您创建账户时所用的电子邮件地址和密码登录来获得此身份。强烈建议您不使用 根用户 执行日常任务,即使是管理任务。请遵守仅将 根用户 用于创建首个 IAM 用户的最佳实践。然后请妥善保存 根用户 凭证,仅用它们执行少数账户和服务管理任务。

IAM 用户和群组IAM 用户是 AWS 账户内对某个人员或应用程序具有特定权限的一个身份。IAM 用户可以拥有长期凭证,例如用户名和密码或一组访问密钥。要了解如何生成访问密钥,请参阅 IAM 用户指南 中的管理 IAM 用户的访问密钥。为 IAM 用户生成访问密钥时,请确保查看并安全保存密钥对。您以后无法找回秘密访问密钥,而是必须生成新的访问密钥对。

IAM 组 是指定一个 IAM 用户集合的身份。您不能使用组的身份登录。您可以使用组来一次性为多个用户指定权限。如果有大量用户,使用组可以更轻松地管理用户权限。例如,您有一个名为 IAMAdmins 的组并为该组授予管理 IAM 资源的权限。

用户与角色不同。用户唯一地与某个人员或应用程序关联,而角色旨在让需要它的任何人代入。用户具有永久的长期凭证,而角色提供临时凭证。要了解更多信息,请参阅 IAM 用户指南 中的何时创建 IAM 用户(而不是角色)。

IAM 角色IAM 角色 是 AWS 账户中具有特定权限的实体。它类似于 IAM 用户,但未与特定人员关联。您可以通过切换角色,在 AWS 管理控制台中暂时代入 IAM 角色。您可以调用 AWS CLI 或 AWS API 操作或使用自定义URL 以代入角色。有关使用角色方法的更多信息,请参阅 IAM 用户指南 中的使用 IAM 角色。

具有临时凭证的 IAM 角色在以下情况下很有用:

• 临时 IAM 用户权限 – IAM 用户可代入 IAM 角色,暂时获得针对特定任务的不同权限。• 联合身份用户访问 – 您也可以不创建 IAM 用户,而是使用来自 AWS Directory Service、您的企业用户

目录或 Web 身份提供商的现有身份。这些用户被称为联合身份用户。在通过身份提供商请求访问权限时,AWS 将为联合身份用户分配角色。有关联合身份用户的更多信息,请参阅 IAM 用户指南 中的联合身份用户和角色。

• 跨账户访问 – 您可以使用 IAM 角色允许其他账户中的某个人(可信任委托人)访问您账户中的资源。角色是授予跨账户访问权限的主要方式。但是,对于某些 AWS 服务,您可以将策略直接附加到资源(而不是

82

Page 87: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南使用策略管理访问

使用角色作为代理)。要了解用于跨账户访问的角色和基于资源的策略之间的差别,请参阅 IAM 用户指南中的 IAM 角色与基于资源的策略有何不同。

• AWS 服务访问 –服务角色是服务代表您在您的账户中执行操作而担任的 IAM 角色。在设置一些 AWS 服务环境时,您必须为服务定义要代入的角色。这个服务角色必须包含该服务访问所需的 AWS 资源会用到的所有必要权限。服务角色因服务而异,但只要您满足服务记录在案的要求,许多服务都允许您选择权限。服务角色只在您的账户内提供访问权限,不能用于为访问其他账户中的服务授权。您可以在 IAM 中创建、修改和删除服务角色。例如,您可以创建一个角色,此角色允许 Amazon Redshift 代表您访问 Amazon S3存储桶,然后将该存储桶中的数据加载到 Amazon Redshift 集群中。有关更多信息,请参阅 IAM 用户指南中的创建角色以向 AWS 服务委派权限。

• 在 Amazon EC2 上运行的应用程序–对于在 EC2 实例上运行、并发出 AWS CLI 或 AWS API 请求的应用程序,您可以使用 IAM 角色管理它们的临时凭证。这优先于在 EC2 实例中存储访问密钥。要将 AWS 角色分配给 EC2 实例并使其对该实例的所有应用程序可用,您可以创建一个附加到实例的实例配置文件。实例配置文件包含角色,并使 EC2 实例上运行的程序能够获得临时凭证。有关更多信息,请参阅 IAM 用户指南 中的使用 IAM 角色向在 Amazon EC2 实例上运行的应用程序授予权限。

要了解是否使用 IAM 角色,请参阅 IAM 用户指南 中的何时创建 IAM 角色(而不是用户)。

使用策略管理访问您将创建策略并将其附加到 IAM 身份或 AWS 资源,以便控制 AWS 中的访问。策略是 AWS 中的对象;在与身份或资源相关联时,策略定义它们的权限。在某个实体(根用户、IAM 用户或 IAM 角色)发出请求时,AWS 将评估这些策略。策略中的权限确定是允许还是拒绝请求。大多数策略在 AWS 中存储为 JSON 文档。有关 JSON 策略文档的结构和内容的更多信息,请参阅 IAM 用户指南 中的 JSON 策略概述。

IAM 管理员可以使用策略来指定哪些用户有权访问 AWS 资源,以及他们可以对这些资源执行哪些操作。每个 IAM 实体(用户或角色)在一开始都没有权限。换言之,默认情况下,用户什么都不能做,甚至不能更改他们自己的密码。要为用户授予执行某些操作的权限,管理员必须将权限策略附加到用户。或者,管理员可以将用户添加到具有预期权限的组中。当管理员为某个组授予访问权限时,该组内的全部用户都会获得这些访问权限。

IAM 策略定义操作的权限,无论您使用哪种方法执行操作。例如,假设您有一个允许 iam:GetRole 操作的策略。具有该策略的用户可以从 AWS 管理控制台、AWS CLI 或 AWS API 获取角色信息。

基于身份的策略基于身份的策略是可附加到身份(如 IAM 用户、角色或组)的 JSON 权限策略文档。这些策略控制身份可在何种条件下对哪些资源执行哪些操作。要了解如何创建基于身份的策略,请参阅 IAM 用户指南 中的创建IAM 策略。

基于身份的策略可以进一步归类为内联策略或托管策略。内联策略直接嵌入单个用户、组或角色中。托管策略是可以附加到 AWS 账户中的多个用户、组和角色的独立策略。托管策略包括 AWS 托管策略和客户托管策略。要了解如何在托管策略或内联策略之间进行选择,请参阅 IAM 用户指南 中的在托管策略与内联策略之间进行选择 。

基于资源的策略基于资源的策略是附加到资源 (如 Amazon S3 存储桶) 的 JSON 策略文档。服务管理员可以使用这些策略来定义指定的委托人(账户成员、用户或角色)可以对该资源以及在什么条件执行哪些操作。基于资源的策略是内联策略。没有基于托管资源的策略。

访问控制列表 (ACL)访问控制列表 (ACL) 是一种策略类型,用于控制哪些委托人(账户成员、用户或角色)有权访问资源。ACL类似于基于资源的策略,但它们不使用 JSON 策略文档格式。Amazon S3、AWS WAF 和 Amazon VPC 是支持 ACL 的服务示例。要了解有关 ACL 的更多信息,请参阅Amazon Simple Storage Service 开发人员指南中的访问控制列表 (ACL) 概述。

83

Page 88: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize 如何与 IAM 协同工作

其他策略类型AWS 支持额外的、不太常用的策略类型。这些策略类型可以设置更常用的策略类型向您授予的最大权限。

• 权限边界 – 权限边界是一项高级功能,借助该功能,您可以设置基于身份的策略可以授予 IAM 实体的最大权限(IAM 用户或角色)。您可为实体设置权限边界。这些结果权限是实体的基于身份的策略及其权限边界的交集。在 Principal 中指定用户或角色的基于资源的策略不受权限边界限制。任一项策略中的显式拒绝将覆盖允许。有关权限边界的更多信息,请参阅 IAM 用户指南 中的 IAM 实体的权限边界。

• 服务控制策略 (SCP) – SCP 是 JSON 策略,指定了组织或组织单位 (OU) 在 AWS Organizations 中的最大权限。AWS Organizations 是一项服务,用于分组和集中管理您的企业拥有的多个 AWS 账户。如果在组织内启用了所有功能,则可对任意或全部账户应用服务控制策略 (SCP)。SCP 限制成员账户中实体(包括每个 AWS 账户根用户)的权限。有关 组织 和 SCP 的更多信息,请参阅 AWS Organizations 用户指南 中的 SCP 工作原理。

• 会话策略 – 会话策略是当您以编程方式为角色或联合身份用户创建临时会话时作为参数传递的高级策略。结果会话的权限是用户或角色的基于身份的策略和会话策略的交集。权限也可以来自基于资源的策略。任一项策略中的显式拒绝将覆盖允许。有关更多信息,请参阅 IAM 用户指南 中的会话策略。

多个策略类型当多个类型的策略应用于一个请求时,生成的权限更加复杂和难以理解。要了解 AWS 如何确定在涉及多个策略类型时是否允许请求,请参阅 IAM 用户指南 中的策略评估逻辑。

Amazon Personalize 如何与 IAM 协同工作使用 IAM 来管理 Amazon Personalize 的访问权限之前,您应该了解哪些 IAM 功能可与 AmazonPersonalize 协同工作。要概括了解 Amazon Personalize 及其他 AWS 服务如何与 IAM 协同工作,请参阅IAM 用户指南 中的可与 IAM 协同工作的 AWS 服务。

主题• Amazon Personalize 基于身份的策略 (p. 84)• Amazon Personalize 基于资源的策略 (p. 86)• 基于 Amazon Personalize 标签的授权 (p. 86)• Amazon Personalize IAM 角色 (p. 86)

Amazon Personalize 基于身份的策略使用 IAM 基于身份的策略,您可以指定允许或拒绝操作和资源,以及指定在什么条件下允许或拒绝操作。Amazon Personalize 支持特定操作、资源和条件键。要了解您在 JSON 策略中使用的所有元素,请参阅 IAM 用户指南 中的 IAM JSON 策略元素参考。

操作基于 IAM 身份的策略的 Action 元素描述该策略将允许或拒绝的特定操作。策略操作通常与关联的 AWSAPI 操作同名。此策略用于策略中以授予执行关联操作的权限。

Amazon Personalize 中的策略操作在操作前使用以下前缀:personalize:。例如,要使用 AmazonPersonalize CreateDataset API 操作创建数据集,您应将 personalize:CreateDataset 操作添加到策略中。策略语句必须包括 Action 或 NotAction 元素。Amazon Personalize 定义了自己的一组操作,描述了您可以使用该服务执行的任务。

要在一个语句中指定多项操作,请使用逗号将它们隔开,如以下命令中所示。

"Action": [ "personalize:action1",

84

Page 89: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize 如何与 IAM 协同工作

"personalize:action2"

您也可以使用通配符 (*) 指定多个操作。例如,要指定以单词 Describe 开头的所有操作,请包括以下操作。

"Action": "personalize:Describe*"

要查看 Amazon Personalize 操作的列表,请参阅 IAM 用户指南 中的 Actions Defined by AmazonPersonalize。

资源Resource 元素指定要向其应用操作的对象。语句必须包含 Resource 或 NotResource 元素。您可使用ARN 来指定资源,或使用通配符 (*) 以指明该语句适用于所有资源。

Amazon Personalize 数据集资源具有以下 ARN。

arn:${Partition}:personalize:${Region}:${Account}:dataset/${dataset-name}

有关 ARN 格式的更多信息,请参阅 Amazon 资源名称 (ARN) 和 AWS 服务命名空间。

例如,要在语句中指定 MyDataset 数据集,请使用以下 ARN。

"Resource": "arn:aws:personalize:us-east-1:123456789012:dataset/MyDataset"

要指定属于特定账户的所有数据集,请使用通配符 (*),如以下示例中所示。

"Resource": "arn:aws:personalize:us-east-1:123456789012:dataset/*"

某些 Amazon Personalize 操作(例如用于创建资源的那些操作)不能在特定资源上执行。在这些情况下,您必须使用通配符 (*)。

"Resource": "*"

要查看 Amazon Personalize 资源类型及其 ARN 的列表,请参阅 IAM 用户指南 中的 Resources Definedby Amazon Personalize。要了解可用于指定每个资源的 ARN 的操作,请参阅Actions Defined by AmazonPersonalize。

条件键在 Condition 元素(或 Condition 块)中,可以指定语句生效的条件。Condition 元素是可选的。您可以构建使用条件运算符(例如,等于或小于)的条件表达式,以使策略中的条件与请求中的值相匹配。

如果您在一个语句中指定多个 Condition 元素,或在单个 Condition 元素中指定多个键,则 AWS 使用逻辑 AND 运算评估它们。如果您为单个条件键指定多个值,则 AWS 使用逻辑 OR 运算来评估条件。在授予语句的权限之前必须满足所有的条件。

在指定条件时,您也可以使用占位符变量。例如,仅当 IAM 用户使用其 IAM 用户名进行标记时,您才可为其授予访问资源的权限。有关更多信息,请参阅 IAM 用户指南 中的 IAM 策略元素:变量和标签。

示例

要查看 Amazon Personalize 基于身份的策略的示例,请参阅Amazon Personalize 基于身份的策略示例 (p. 86)。

85

Page 90: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南基于身份的策略示例

Amazon Personalize 基于资源的策略Amazon Personalize 不支持基于资源的策略。

基于 Amazon Personalize 标签的授权Amazon Personalize 不支持标记资源或基于标签的访问控制。

Amazon Personalize IAM 角色IAM 角色是 AWS 账户中具有特定权限的实体。

使用 Amazon Personalize 的临时凭证您可以使用临时凭证进行联合身份登录,代入 IAM 角色或代入跨账户角色。您可以调用 AWS SecurityToken Service (AWS STS) API 操作(如 AssumeRole 或 GetFederationToken)以获得临时安全凭证。

Amazon Personalize 支持使用临时凭证。

服务相关角色服务相关角色允许 AWS 服务访问其他服务中的资源以代表您完成操作。服务相关角色显示在您的 IAM 账户中,并由该服务拥有。IAM 管理员可以查看但不能编辑服务相关角色的权限。

Amazon Personalize 不支持服务相关角色。

服务角色此功能允许服务代表您代入服务角色。此角色允许服务访问其他服务中的资源以代表您完成操作。服务角色显示在您的 IAM 账户中,并由该账户拥有。这意味着 IAM 管理员可以更改此角色的权限。但是,这样操作可能会中断服务的功能。

Amazon Personalize 支持服务角色。

Amazon Personalize 基于身份的策略示例默认情况下,IAM 用户和角色没有创建或修改 Amazon Personalize 资源的权限。它们还无法使用 AWS 管理控制台、AWS CLI 或 AWS API 执行任务。IAM 管理员必须创建 IAM 策略,为用户和角色授予权限,以便对他们所需的指定资源执行特定的 API 操作。然后,管理员必须将这些策略附加到需要这些权限的 IAM 用户或组。

要了解如何使用这些示例 JSON 策略文档创建 IAM 基于身份的策略,请参阅 IAM 用户指南 中的 JSON 选项卡上的创建策略。

主题• 策略最佳实践 (p. 86)• 使用 Amazon Personalize 控制台 (p. 87)• 允许用户查看他们自己的权限 (p. 87)• 授予对 Amazon Personalize 资源的完全访问权限 (p. 88)• 授予对 Amazon Personalize 资源的只读访问权限 (p. 88)

策略最佳实践基于身份的策略非常强大。它们确定某个人是否可以创建、访问或删除您账户中的 Amazon Personalize 资源。这些操作可能会使 AWS 账户产生成本。创建或编辑基于身份的策略时,请遵循以下准则和建议:

86

Page 91: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南基于身份的策略示例

• 开始使用 AWS 托管策略 – 要快速开始使用 Amazon Personalize,请使用 AWS 托管策略,为您的员工授予他们所需的权限。这些策略已在您的账户中提供,并由 AWS 维护和更新。有关更多信息,请参阅 IAM用户指南 中的利用 AWS 托管策略开始使用权限。

• 授予最低权限 – 创建自定义策略时,仅授予执行任务所需的许可。最开始只授予最低权限,然后根据需要授予其他权限。这样做比起一开始就授予过于宽松的权限而后再尝试收紧权限来说更为安全。有关更多信息,请参阅 IAM 用户指南 中的授予最小权限。

• 为敏感操作启用 MFA – 为增强安全性,要求 IAM 用户使用多重身份验证 (MFA) 来访问敏感资源或 API 操作。有关更多信息,请参阅 IAM 用户指南 中的在 AWS 中使用多重身份验证 (MFA)。

• 使用策略条件来增强安全性 – 在切实可行的范围内,定义基于身份的策略在哪些情况下允许访问资源。例如,您可编写条件来指定请求必须来自允许的 IP 地址范围。您也可以编写条件,以便仅允许指定日期或时间范围内的请求,或者要求使用 SSL 或 MFA。有关更多信息,请参阅 IAM 用户指南 中的 IAM JSON 策略元素:Condition。

使用 Amazon Personalize 控制台要访问 Amazon Personalize 控制台,您必须拥有一组最低的权限。这些权限必须允许您列出和查看有关您的 AWS 账户中的 Amazon Personalize 资源的详细信息。如果创建比必需的最低权限更为严格的基于身份的策略,对于附加了该策略的实体(IAM 用户或角色),控制台将无法按预期正常运行。

为确保这些实体仍可使用 Amazon Personalize 控制台,也可向实体附加以下 AWS 托管策略。有关更多信息,请参阅 IAM 用户指南 中的为用户添加权限。

AWSPersonalizeConsoleAccess

对于仅调用 AWS CLI 或 AWS API 的用户,您不需要允许最低控制台权限。相反,只允许访问与您尝试执行的 API 操作相匹配的操作。

允许用户查看他们自己的权限此示例显示您可以如何创建策略,以便允许 IAM 用户查看附加到其用户身份的内联和托管策略。此策略包括在控制台上完成此操作或者以编程方式使用 AWS CLI 或 AWS API 所需的权限。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ViewOwnUserInfo", "Effect": "Allow", "Action": [ "iam:GetUserPolicy", "iam:ListGroupsForUser", "iam:ListAttachedUserPolicies", "iam:ListUserPolicies", "iam:GetUser" ], "Resource": ["arn:aws:iam::*:user/${aws:username}"] }, { "Sid": "NavigateInConsole", "Effect": "Allow", "Action": [ "iam:GetGroupPolicy", "iam:GetPolicyVersion", "iam:GetPolicy", "iam:ListAttachedGroupPolicies", "iam:ListGroupPolicies", "iam:ListPolicyVersions", "iam:ListPolicies",

87

Page 92: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南基于身份的策略示例

"iam:ListUsers" ], "Resource": "*" } ]}

授予对 Amazon Personalize 资源的完全访问权限以下示例为您 AWS 账户中的某个 IAM 用户授予对所有 Amazon Personalize 资源和操作的完全访问权限。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "personalize:*" ], "Resource": "*" } ]}

授予对 Amazon Personalize 资源的只读访问权限在此示例中,您向 AWS 账户中的 IAM 用户授予了对 Amazon Personalize 资源(包括 Amazon Personalize数据集、数据集组、解决方案和市场活动)的只读访问权限。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "personalize:DescribeAlgorithm", "personalize:DescribeBatchInferenceJob", "personalize:DescribeCampaign", "personalize:DescribeDataset", "personalize:DescribeDatasetGroup", "personalize:DescribeDatasetImportJob", "personalize:DescribeDatasetImportJobRun", "personalize:DescribeEventTracker", "personalize:DescribeFeatureExportJob", "personalize:DescribeFeatureTransformation", "personalize:DescribeRecipe", "personalize:DescribeSchema", "personalize:DescribeSolution", "personalize:DescribeSolutionVersion", "personalize:GetSolutionMetrics", "personalize:ListBatchInferenceJobs", "personalize:ListCampaigns", "personalize:ListDatasetGroups", "personalize:ListDatasetImportJobs", "personalize:ListDatasets", "personalize:ListEventTrackers", "personalize:ListRecipes", "personalize:ListSchemas", "personalize:ListSolutions", "personalize:ListSolutionVersions" ], "Resource": "*"

88

Page 93: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南故障排除

} ]}

故障排除 Amazon Personalize 身份和访问使用以下信息可帮助您诊断和修复在使用 Amazon Personalize 和 IAM 时可能遇到的常见问题。

主题• 我无权在 Amazon Personalize 中执行操作 (p. 89)• 我无权执行 iam:PassRole (p. 89)• 我想要查看我的访问密钥 (p. 89)• 我是管理员并希望允许其他人访问 Amazon Personalize (p. 90)• 我想要允许我的 AWS 账户之外的用户访问我的 Amazon Personalize 资源 (p. 90)

我无权在 Amazon Personalize 中执行操作如果 AWS 管理控制台 告诉您,您无权执行某个操作,则必须联系您的管理员寻求帮助。您的管理员是指为您提供用户名和密码的那个人。

当 mateojackson IAM 用户尝试使用控制台查看有关 widget 的详细信息,但不具有personalize:GetWidget 权限时,会发生以下示例错误。

User: arn:aws:iam::123456789012:user/mateojackson is not authorized to perform: personalize:GetWidget on resource: my-example-widget

在这种情况下,Mateo 请求他的管理员更新其策略,以允许他使用 personalize:GetWidget 操作访问my-example-widget 资源。

我无权执行 iam:PassRole如果您收到错误消息,提示您无权执行 iam:PassRole 操作,则必须联系您的管理员寻求帮助。您的管理员是指为您提供用户名和密码的那个人。请求那个人更新您的策略,以便允许您将角色传递给 AmazonPersonalize。

有些 AWS 服务允许您将现有角色传递到该服务,而不是创建新服务角色或服务相关角色。为此,您必须具有将角色传递到服务的权限。

当名为 marymajor 的 IAM 用户尝试使用控制台在 Amazon Personalize 中执行操作时,会发生以下示例错误。但是,服务必须具有服务角色所授予的权限才可执行操作。Mary 不具有将角色传递到服务的权限。

User: arn:aws:iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole

在这种情况下,Mary 请求她的管理员来更新其策略,以允许她执行 iam:PassRole 操作。

我想要查看我的访问密钥创建 IAM 用户访问密钥之后,您可以随时查看您的访问密钥 ID。但是,您无法再查看您的秘密访问密钥。如果您丢失了私有密钥,则必须创建一个新的访问密钥对。

访问密钥包含两部分:访问密钥 ID(例如 AKIAIOSFODNN7EXAMPLE)和秘密访问密钥(例如wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY)。与用户名和密码一样,您必须同时使用访问密钥ID 和秘密访问密钥对请求执行身份验证。像对用户名和密码一样,安全地管理访问密钥。

89

Page 94: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南日志记录和监控

Important

请不要向第三方提供访问密钥,甚至为了帮助找到您的规范用户 ID 也不能提供。如果您这样做,可能会向某人提供对您的账户的永久访问权限。

当您创建访问密钥对时,系统会提示您将访问密钥 ID 和秘密访问密钥保存在一个安全位置。秘密访问密钥仅在您创建它时可用。如果您丢失了秘密访问密钥,则必须向您的 IAM 用户添加新的访问密钥。您最多可拥有两个访问密钥。如果您已有两个密钥,则必须删除一个密钥对,然后再创建新的密钥。要查看说明,请参阅IAM 用户指南 中的管理访问密钥。

我是管理员并希望允许其他人访问 Amazon Personalize要允许其他人访问 Amazon Personalize,您必须为需要访问权限的人员或应用程序创建 IAM 实体(用户或角色)。他们(它们)将使用该实体的凭证访问 AWS。然后,您必须将策略附加到实体,以便在 AmazonPersonalize 中为他们(它们)授予正确的权限。

要立即开始使用,请参阅 IAM 用户指南 中的创建您的第一个 IAM 委托用户和组。

我想要允许我的 AWS 账户之外的用户访问我的 AmazonPersonalize 资源您可以创建一个角色,以便其他账户中的用户或您组织外的人员可以使用该角色来访问您的资源。您可以指定谁值得信赖,可以代入角色。对于支持基于资源的策略或访问控制列表 (ACL) 的服务,您可以使用这些策略向人员授予对您的资源的访问权。

要了解更多信息,请参阅以下内容:

• 要了解 Amazon Personalize 是否支持这些功能,请参阅Amazon Personalize 如何与 IAM 协同工作 (p. 84)。

• 要了解如何向您拥有的 AWS 账户中的资源提供访问权限,请参阅 IAM 用户指南 中的对您拥有的 AWS 账户中的 IAM 用户提供访问权限。

• 要了解如何向第三方 AWS 账户提供对您的资源的访问权限,请参阅 IAM 用户指南 中的向第三方拥有的AWS 账户提供访问权限。

• 要了解如何通过联合身份验证提供访问权限,请参阅 IAM 用户指南 中的向经过外部身份验证的用户(联合身份验证)提供访问权限。

• 要了解使用角色和基于资源的策略进行跨账户访问之间的差别,请参阅 IAM 用户指南 中的 IAM 角色和基于资源的策略有何不同。

Amazon Personalize 中的日志记录和监控本节提供有关使用 Amazon CloudWatch 和 AWS CloudTrail 对 Amazon Personalize 进行监控和日志记录的信息。

主题• 监控 Amazon Personalize (p. 90)• Amazon Personalize 的 CloudWatch 指标 (p. 93)• 使用 AWS CloudTrail 记录 Amazon Personalize API 调用 (p. 95)

监控 Amazon Personalize利用 Amazon CloudWatch,您可以获取与 Amazon Personalize 关联的指标。您可以设置警报,以便在一个或多个指标超出定义的阈值时通知您。要查看指标,您可以使用 Amazon CloudWatch、Amazon AWSCommand Line Interface 或 CloudWatch API。

90

Page 95: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南监控

您还可以使用 Amazon Personalize 控制台查看选定时段内的聚合指标。

使用 Amazon Personalize 的 CloudWatch 指标要使用指标,您必须指定以下信息:

• 指标名称。• 指标维度。维度 是帮助您对某指标进行唯一标识的名称/值对。

您可以使用 AWS 管理控制台、AWS CLI 或 CloudWatch API 获得 Amazon Personalize 的监控数据。您也可以通过某个 Amazon AWS 软件开发工具包 (SDK) 或 CloudWatch API 工具来使用 CloudWatch API。控制台将根据来自 CloudWatch API 的原始数据显示一系列图表。根据您的需求差异,您可能倾向于使用控制台中显示的图表,也可能倾向于检索自 API 的图表。

以下列表显示了这些指标的一些常见用途。下面列出的是能够带您入门的启发式问题,但并不全面。

如何? 相关指标

如何跟踪已记录的事件数。 监控 PutEventsRequests 指标。

如何监控我 DatasetImportJob 错误? 使用 DatasetImportJobError 指标。

我如何监控 GetRecommendations 调用的延迟? 使用 GetRecommendationsLatency 指标。

您必须具有适当的 CloudWatch 权限才能使用 CloudWatch 监控 Amazon Personalize。有关更多信息,请参阅 Amazon CloudWatch 的身份验证和访问控制。

访问 Amazon Personalize 指标以下示例说明如何使用 CloudWatch 控制台、AWS CLI 和 CloudWatch API 访问 Amazon Personalize 指标。

查看指标 (控制台)

1. 登录 AWS 管理控制台并通过以下网址打开 CloudWatch 控制台:https://console.aws.amazon.com/cloudwatch/。

2. 选择 Metrics (指标),再选择 All Metrics (所有指标) 选项卡,然后选择 AWS/Personalize (AWS/个性化)。

3. 选择指标维度。4. 从列表中选择所需的指标,然后为图表选择时间段。

查看在一段时间内收到的事件的指标 (CLI)

• 打开 AWS CLI 并输入以下命令:

aws cloudwatch get-metric-statistics \ --metric-name PutEventsRequests \ --start-time 2019-03-15T00:00:20Z \ --period 3600 \ --end-time 2019-03-16T00:00:00Z \ --namespace AWS/Personalize \ --dimensions Name=EventTrackerArn,Value=EventTrackerArn \ --statistics Sum

91

Page 96: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南监控

此示例显示在一段时间内为给定事件跟踪程序 ARN 接收的事件。有关更多信息,请参阅 get-metric-statistics。

访问指标 (CloudWatch API)

• 调用 GetMetricStatistics。有关更多信息,请参见 Amazon CloudWatch API Reference。

创建警报您可以创建 CloudWatch 警报,用于在警报改变状态时发送 Amazon Simple Notification Service (AmazonSNS) 消息。警报会在您规定的时间范围内监控某一项指标。警报会根据指标值在多个时间段内对比给定阈值的情况执行一项或多项操作。操作是向 Amazon SNS 主题或 AWS Auto Scaling 策略发送通知。

警报只会调用操作进行持续的状态变更。CloudWatch 警报将不会调用操作,因为这些操作处于特定状态。该状态必须改变并在指定数量的时间段内一直保持。

设置警报 (控制台)

1. 登录 AWS 管理控制台并通过以下网址打开 CloudWatch 控制台:https://console.aws.amazon.com/cloudwatch/。

2. 在导航窗格中,选择 Alarms (警报),然后选择 Create Alarm (创建警报)。创建警报向导随即启动。3. 选择选择指标。4. 在 All metrics (所有指标) 选项卡中,选择 AWS/Personalize (AWS/个性化)。5. 选择 EventTrackerArn,然后选择 PutEventsRequests。6. 选择 Graphed metrics 选项卡。7. 对于统计数据,选择总计。8. 选择选择指标。9. 填写 Name 和 Description。对于 Whenever (每当此时),选择 >,然后输入您选择的最大值。10. 如果您希望 CloudWatch 在达到警报状态时向您发送一封电子邮件,对于 Whenever this alarm: (每当此

警报:),请选择 State is ALARM (状态为“警报”)。要将警报发送到现有 Amazon SNS 主题,对于 Sendnotification to: (发送通知到:),请选择现有 SNS 主题。要为新的电子邮件订阅列表设置名称和电子邮件地址,请选择新建列表。CloudWatch 将保存列表并将其显示在字段中,以便您可使用它来设置将来的警报。

Note

如果您使用新建列表创建一个新的 Amazon SNS 主题,则必须先验证电子邮件地址,然后目标收件人才能接收通知。Amazon SNS 仅在警报进入警报状态时发送电子邮件。如果在验证电子邮件地址之前警报状态发生了变化,那么目标收件人不会接收到通知。

11. 选择 Create alarm (创建警报)。

设置警报 (AWS CLI)

• 打开 AWS CLI,然后输入以下命令。更改 alarm-actions 参数的值,以引用您之前创建的 AmazonSNS 主题。

aws cloudwatch put-metric-alarm \ --alarm-name PersonalizeCLI \ --alarm-description "Alarm when more than 10 events occur" \ --metric-name PutEventsRequests \ --namespace AWS/Personalize \ --statistic Sum \ --period 300 \

92

Page 97: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize 的 CloudWatch 指标

--threshold 10 \ --comparison-operator GreaterThanThreshold \ --evaluation-periods 1 \ --unit Count \ --dimensions Name=EventTrackerArn,Value=EventTrackerArn \ --alarm-actions SNSTopicArn

此示例显示如何为在 5 分钟内针对给定事件跟踪程序 ARN 发生 10 个以上的事件的情况创建警报。有关更多信息,请参阅 put-metric-alarm。

设置警报 (CloudWatch API)

• 调用 PutMetricAlarm。有关更多信息,请参阅 Amazon CloudWatch API Reference。

Amazon Personalize 的 CloudWatch 指标本节包含对 Amazon Personalize 可用的 Amazon CloudWatch 指标的信息。您也可以从 AmazonPersonalize 控制台查看 Amazon Personalize 指标的聚合视图。有关更多信息,请参阅 监控 AmazonPersonalize (p. 90)。

下表列出了 Amazon Personalize 指标。所有指标均支持以下统计数据:Average, Minimum, Maximum,Sum。

指标 说明

DatasetImportJobRequests 成功的 CreateDatasetImportJob (p. 115) API 调用的数量。

维度: DatasetGroupArn, DatasetArn,DatasetImportJobArn

DatasetImportJobError 导致错误的 CreateDatasetImportJob API 调用的数量。

维度: DatasetGroupArn, DatasetArn,DatasetImportJobArn

DatasetImportJobExecutionTime CreateDatasetImportJob API 调用与操作完成(或发生故障)之间的时间。

维度: DatasetGroupArn, DatasetArn,DatasetImportJobArn

单位:秒

DatasetSize 由数据集导入任务导入的数据的大小。

维度: DatasetGroupArn, DatasetArn,DatasetImportJobArn

单位:字节

SolutionTrainingJobRequests 成功的 CreateSolutionVersion (p. 128) API 调用的数量。

维度: SolutionArn, SolutionVersionArn

SolutionTrainingJobError 导致错误的 CreateSolutionVersion API 调用的数量。

维度: SolutionArn, SolutionVersionArn

93

Page 98: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize 的 CloudWatch 指标

指标 说明

SolutionTrainingJobExecutionTimeCreateSolutionVersion API 调用与操作完成(或发生故障)之间的时间。

维度: SolutionArn, SolutionVersionArn

单位:秒

GetPersonalizedRankingRequests 成功的 GetPersonalizedRanking (p. 202) API 调用的数量。

维度:CampaignArn

GetPersonalizedRanking4xxErrors 4xx HTTP 响应代码返回的 GetPersonalizedRanking API调用的数量。

维度:CampaignArn

GetPersonalizedRanking5xxErrors 5xx HTTP 响应代码返回的 GetPersonalizedRanking API调用的数量。

维度:CampaignArn

GetPersonalizedRankingLatency 接收 GetPersonalizedRanking API 调用与发送推荐(不包括 4xx 和 5xx 错误)之间的时间。

维度:CampaignArn

单位:毫秒

GetRecommendationsRequests 成功的 GetRecommendations (p. 204) API 调用的数量。

维度:CampaignArn

GetRecommendations4xxErrors 4xx HTTP 响应代码返回的 GetRecommendations API 调用的数量。

维度:CampaignArn

GetRecommendations5xxErrors 5xx HTTP 响应代码返回的 GetRecommendations API 调用的数量。

维度:CampaignArn

GetRecommendationsLatency 接收 GetRecommendations API 调用与发送推荐(不包括4xx 和 5xx 错误)之间的时间。

维度:CampaignArn

单位:毫秒

PutEventsRequests 成功的 PutEvents (p. 200) API 调用的数量。

维度: EventTrackerArn

PutEvents4xxErrors 4xx HTTP 响应代码返回的 PutEvents API 调用的数量。

维度:EventTrackerArn

94

Page 99: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南使用 AWS CloudTrail 记录 Amazon Personalize API 调用

指标 说明

PutEvents5xxErrors 5xx HTTP 响应代码返回的 PutEvents API 调用的数量。

维度:EventTrackerArn

PutEventsLatency 完成 PutEvents API 调用(不包括 4xx 和 5xx 错误)花费的时间。

维度:EventTrackerArn

单位:毫秒

使用 AWS CloudTrail 记录 Amazon Personalize API 调用Amazon Personalize 与 AWS CloudTrail 集成,后者是在 Amazon Personalize 中提供用户、角色或 AWS服务所采取操作的记录的服务。CloudTrail 将对 Amazon Personalize 的 API 调用子集作为事件捕获,包括来自 Amazon Personalize 控制台的调用和对 Amazon Personalize API 的代码调用。如果您创建跟踪,则可以使 CloudTrail 事件持续交付到 Amazon S3 存储桶(包括 Amazon Personalize 的事件)。如果您不配置跟踪,则仍可在 CloudTrail 控制台的 Event history (事件历史记录) 中查看最新事件。通过使用 CloudTrail 收集的信息,您可以确定向 Amazon Personalize 发出了什么请求、发出请求的 IP 地址、何人发出的请求、请求的发出时间以及其他详细信息。

要了解有关 CloudTrail 的更多信息(包括如何配置和启用),请参阅 AWS CloudTrail User Guide。

CloudTrail 中的 Amazon Personalize 信息在您创建 AWS 账户时,即针对该账户启用了 CloudTrail。当 Amazon Personalize 中发生受支持的事件活动时,该活动将记录在 CloudTrail 事件中,并与其他 AWS 服务事件一同保存在 Event history (事件历史记录)中。您可以在 AWS 账户中查看、搜索和下载最新事件。有关更多信息,请参阅使用 CloudTrail 事件历史记录查看事件。

要持续记录 AWS 账户中的事件(包括 Amazon Personalize 的事件),请创建跟踪。通过跟踪,CloudTrail可将日志文件传送至 Amazon S3 存储桶。默认情况下,在控制台中创建跟踪时,此跟踪应用于所有区域。此跟踪在 AWS 分区中记录所有区域中的事件,并将日志文件传送至您指定的 Amazon S3 存储桶。此外,您可以配置其他 AWS 服务,进一步分析在 CloudTrail 日志中收集的事件数据并采取操作。有关更多信息,请参阅:

• 创建跟踪概述• CloudTrail 支持的服务和集成• 为 CloudTrail 配置 Amazon SNS 通知• 接收多个区域中的 CloudTrail 日志文件和从多个账户中接收 CloudTrail 日志文件

Amazon Personalize 支持将所有操作(API 操作)作为事件记录在 CloudTrail 日志文件中。有关更多信息,请参阅 Actions (p. 100)。

每个事件或日志条目都包含有关生成请求的人员的信息。身份信息帮助您确定以下内容:

• 请求是使用根用户凭证还是 IAM 用户凭证发出的。• 请求是使用角色还是联合身份用户的临时安全凭证发出的。• 请求是否由其他 AWS 服务发出。

有关更多信息,请参阅 CloudTrail userIdentity 元素。

95

Page 100: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南合规性验证

示例:Amazon Personalize 日志文件条目跟踪是一种配置,可用于将事件作为日志文件传送到您指定的 Amazon S3 存储桶。CloudTrail 日志文件包含一个或多个日志条目。一个事件表示来自任何源的一个请求,包括有关所请求的操作、操作的日期和时间、请求参数等方面的信息。CloudTrail 日志文件不是公用 API 调用的有序堆栈跟踪,因此它们不会以任何特定顺序显示。

以下示例说明了 CloudTrail 日志条目以及 ListDatasetGroups API 操作的操作:

{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "principal-id", "arn": "arn:aws:iam::user-arn", "accountId": "account-id", "accessKeyId": "access-key, "userName": "user-name" }, "eventTime": "2018-11-22T02:18:03Z", "eventSource": "personalize.amazonaws.com", "eventName": "ListDatasetGroups", "awsRegion": "us-west-2", "sourceIPAddress": "source-ip-address", "userAgent": "aws-cli/1.11.16 Python/2.7.11 Darwin/15.6.0 botocore/1.4.73", "requestParameters": null, "responseElements": { "datasetGroups": [ { "name": "testdatasetgroup", "datasetGroupArn": "arn:aws:personalize:us-west-2:nnnnnnnnnn:dataset-group/testdataset", "status": "ACTIVE", "creationDateTime": "Nov 5, 2018 6:06:01 AM" } ] }, "requestID": "request-id", "eventID": "event-id", "eventType": "AwsApiCall", "recipientAccountId": "recipient-account-id"}

Amazon Personalize 的合规性验证作为多项 AWS 合规性计划的一部分,第三方审计员将评估 Amazon Personalize 的安全性和合规性。其中包括 SOC、PCI、HIPAA 等。

有关特定合规性计划范围内的 AWS 服务列表,请参阅合规性计划范围内的 AWS 服务。有关常规信息,请参阅 AWS 合规性计划。

您可以使用 AWS Artifact 下载第三方审计报告。有关更多信息,请参阅下载 AWS 构件中的报告。

您在使用 Amazon Personalize 时的合规性责任由您数据的敏感性、您公司的合规性目标以及适用的法律法规决定。AWS 提供以下资源来帮助实现合规性:

• 安全性与合规性快速入门指南 – 这些部署指南讨论了架构注意事项,并提供了在 AWS 上部署基于安全性和合规性的基准环境的步骤。

• 《设计符合 HIPAA 安全性和合规性要求的架构》白皮书 – 此白皮书介绍公司如何使用 AWS 创建符合HIPAA 标准的应用程序。

96

Page 101: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南恢复功能

• AWS 合规性资源 – 此业务手册和指南集合可能适用于您的行业和位置。• AWS Config 开发人员指南中的使用规则评估资源 – 此 AWS Config 服务评估您的资源配置对内部实践、

行业指南和法规的遵循情况。• AWS Security Hub – 此 AWS 服务提供了 AWS 中安全状态的全面视图,可帮助您检查是否符合安全行业

标准和最佳实践。

Amazon Personalize 中的弹性AWS 全球基础设施围绕 AWS 区域和可用区构建。AWS 区域提供多个在物理上独立且隔离的可用区,这些可用区通过延迟低、吞吐量高且冗余性高的网络连接在一起。利用可用区,您可以设计和操作在可用区之间无中断地自动实现故障转移的应用程序和数据库。与传统的单个或多个数据中心基础设施相比,可用区具有更高的可用性、容错性和可扩展性。

有关 AWS 区域和可用区的更多信息,请参阅 AWS 全球基础设施。

Amazon Personalize 中的基础设施安全性作为一项托管服务,Amazon Personalize 由 Amazon Web Services:安全流程概述白皮书中所述的 AWS全球网络安全程序提供保护。

您可以使用 AWS 发布的 API 调用通过网络访问 Amazon Personalize。客户端必须支持传输层安全性 (TLS)1.0 或更高版本。建议使用 TLS 1.2 或更高版本。客户端还必须支持具有完全向前保密 (PFS) 的密码套件,例如 Ephemeral Diffie-Hellman (DHE) 或 Elliptic Curve Ephemeral Diffie-Hellman (ECDHE)。大多数现代系统(如 Java 7 及更高版本)都支持这些模式。

此外,必须使用访问密钥 ID 和与 IAM 委托人关联的秘密访问密钥来对请求进行签名。或者,您可以使用AWS Security Token Service (AWS STS) 生成临时安全凭证来对请求进行签名。

97

Page 102: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南支持的 AWS 区域

Amazon Personalize 中的限制以下各个部分包含有关 Amazon Personalize 准则和限制的信息。

主题• 支持的 AWS 区域 (p. 98)• 合规性 (p. 98)• 服务限制 (p. 98)

支持的 AWS 区域有关支持 Amazon Personalize 的 AWS 区域的列表,请参阅 Amazon Web Services 一般参考 中的 AWS 区域和终端节点。

合规性有关 Amazon Personalize 合规性计划的更多信息,请参阅 AWS 合规性、AWS 合规性计划和合规性计划范围内的 AWS 服务。

服务限制您的 AWS 账户存在以下 Amazon Personalize 限制。

资源 限制

HRNN、SIMS、热门程度计数和个性化排名配方的单个数据集(用户、项目或交互)的最大数据量。

100 GB

HRNN 元数据和 HRNN 冷启动配方的交互数据集的最大数据量。 100 GB

HRNN 元数据和 HRNN 冷启动配方的用户和项目数据集的最大组合数据量。 5GB

训练模型(训练模型意味着您创建解决方案版本)所需的唯一组合历史和事件交互(按 eventType 和 eventValueThreshold 筛选之后,如果提供)的最小数量。

1000

训练模型(训练模型意味着您创建解决方案版本)所需的最小唯一用户数(每个用户至少 2 个交互)。

25

模型在训练期间考虑的最大交互数。 5 亿

模型在训练期间考虑的最大项目数。 75 万

HRNN 冷启动配方支持训练模型的最大冷启动项目数(训练模型意味着您创建解决方案版本)。

80,000

HRNN 冷启动配方训练模型所需的最小冷启动项目数(训练模型意味着您创建解决方案版本)。

100

98

Page 103: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南服务限制

资源 限制

最大事务速率(GetRecommendations 和 GetPersonalizedRanking 请求)。 2500 个/秒

每个活动每秒的最大 GetRecommendations 请求数。 500 个/秒

每个活动每秒的最大 GetPersonalizedRanking 请求数。 500 个/秒

PutEvents 请求的最大数量。 1000 个/秒

PutEvents 调用中的事件的最大数量。 10

事件的最大大小。 10 KB

批处理推理作业中输入文件的最大数量。 1000

批处理推理作业输入的最大大小。 1GB

批处理推理作业中每个输入文件的最大记录数。 5000 万

您的 AWS 账户对于 Amazon Personalize 具有每个区域的以下限制。

资源 限制

有效架构的总数。 500

有效数据集的总数。 500

有效数据集组的总数。 500

有效事件跟踪程序的总数。 500

有效解决方案的总数。 500

有效市场活动的总数。 5

99

Page 104: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Actions

API 参考本节提供 Amazon Personalize API 操作的文档。

ActionsThe following actions are supported by Amazon Personalize:

• CreateBatchInferenceJob (p. 103)• CreateCampaign (p. 106)• CreateDataset (p. 109)• CreateDatasetGroup (p. 112)• CreateDatasetImportJob (p. 115)• CreateEventTracker (p. 118)• CreateSchema (p. 121)• CreateSolution (p. 123)• CreateSolutionVersion (p. 128)• DeleteCampaign (p. 131)• DeleteDataset (p. 133)• DeleteDatasetGroup (p. 135)• DeleteEventTracker (p. 137)• DeleteSchema (p. 139)• DeleteSolution (p. 141)• DescribeAlgorithm (p. 143)• DescribeBatchInferenceJob (p. 145)• DescribeCampaign (p. 147)• DescribeDataset (p. 149)• DescribeDatasetGroup (p. 151)• DescribeDatasetImportJob (p. 153)• DescribeEventTracker (p. 155)• DescribeFeatureTransformation (p. 157)• DescribeRecipe (p. 159)• DescribeSchema (p. 161)• DescribeSolution (p. 163)• DescribeSolutionVersion (p. 166)• GetSolutionMetrics (p. 169)• ListBatchInferenceJobs (p. 171)• ListCampaigns (p. 174)• ListDatasetGroups (p. 177)• ListDatasetImportJobs (p. 179)• ListDatasets (p. 182)• ListEventTrackers (p. 185)• ListRecipes (p. 187)

100

Page 105: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

• ListSchemas (p. 189)• ListSolutions (p. 191)• ListSolutionVersions (p. 194)• UpdateCampaign (p. 197)

The following actions are supported by Amazon Personalize Events:

• PutEvents (p. 200)

The following actions are supported by Amazon Personalize Runtime:

• GetPersonalizedRanking (p. 202)• GetRecommendations (p. 204)

Amazon PersonalizeThe following actions are supported by Amazon Personalize:

• CreateBatchInferenceJob (p. 103)• CreateCampaign (p. 106)• CreateDataset (p. 109)• CreateDatasetGroup (p. 112)• CreateDatasetImportJob (p. 115)• CreateEventTracker (p. 118)• CreateSchema (p. 121)• CreateSolution (p. 123)• CreateSolutionVersion (p. 128)• DeleteCampaign (p. 131)• DeleteDataset (p. 133)• DeleteDatasetGroup (p. 135)• DeleteEventTracker (p. 137)• DeleteSchema (p. 139)• DeleteSolution (p. 141)• DescribeAlgorithm (p. 143)• DescribeBatchInferenceJob (p. 145)• DescribeCampaign (p. 147)• DescribeDataset (p. 149)• DescribeDatasetGroup (p. 151)• DescribeDatasetImportJob (p. 153)• DescribeEventTracker (p. 155)• DescribeFeatureTransformation (p. 157)• DescribeRecipe (p. 159)• DescribeSchema (p. 161)• DescribeSolution (p. 163)• DescribeSolutionVersion (p. 166)• GetSolutionMetrics (p. 169)• ListBatchInferenceJobs (p. 171)

101

Page 106: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

• ListCampaigns (p. 174)• ListDatasetGroups (p. 177)• ListDatasetImportJobs (p. 179)• ListDatasets (p. 182)• ListEventTrackers (p. 185)• ListRecipes (p. 187)• ListSchemas (p. 189)• ListSolutions (p. 191)• ListSolutionVersions (p. 194)• UpdateCampaign (p. 197)

102

Page 107: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateBatchInferenceJobService: Amazon Personalize

Creates a batch inference job. The operation can handle up to 50 million records and the input file must bein JSON format. For more information, see 获取批量推荐 (p. 75).

Request Syntax

{ "jobInput": { "s3DataSource": { "kmsKeyArn": "string", "path": "string" } }, "jobName": "string", "jobOutput": { "s3DataDestination": { "kmsKeyArn": "string", "path": "string" } }, "numResults": number, "roleArn": "string", "solutionVersionArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

jobInput (p. 103)

The Amazon S3 path that leads to the input file to base your recommendations on. The input materialmust be in JSON format.

Type: BatchInferenceJobInput (p. 217) object

Required: YesjobName (p. 103)

The name of the batch inference job to create.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: YesjobOutput (p. 103)

The path to the Amazon S3 bucket where the job's output will be stored.

Type: BatchInferenceJobOutput (p. 218) object

Required: YesnumResults (p. 103)

The number of recommendations to retreive.

103

Page 108: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: Integer

Required: NoroleArn (p. 103)

The ARN of the Amazon Identity and Access Management role that has permissions to read and writeto your input and out Amazon S3 buckets respectively.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+

Required: YessolutionVersionArn (p. 103)

The Amazon Resource Name (ARN) of the solution version that will be used to generate the batchinference recommendations.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "batchInferenceJobArn": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

batchInferenceJobArn (p. 104)

The ARN of the batch inference job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400

104

Page 109: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

LimitExceededException

The limit on the number of requests per second has been exceeded.

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

105

Page 110: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateCampaignService: Amazon Personalize

Creates a campaign by deploying a solution version. When a client calls the GetRecommendations andGetPersonalizedRanking APIs, a campaign is specified in the request.

Minimum Provisioned TPS and Auto-Scaling

A transaction is a single GetRecommendations or GetPersonalizedRanking call. Transactions persecond (TPS) is the throughput and unit of billing for Amazon Personalize. The minimum provisionedTPS (minProvisionedTPS) specifies the baseline throughput provisioned by Amazon Personalize,and thus, the minimum billing charge. If your TPS increases beyond minProvisionedTPS, AmazonPersonalize auto-scales the provisioned capacity up and down, but never below minProvisionedTPS,to maintain a 70% utilization. There's a short time delay while the capacity is increased that might causeloss of transactions. It's recommended to start with a low minProvisionedTPS, track your usage usingAmazon CloudWatch metrics, and then increase the minProvisionedTPS as necessary.

Status

A campaign can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

To get the campaign status, call DescribeCampaign (p. 147).

Note

Wait until the status of the campaign is ACTIVE before asking the campaign forrecommendations.

Related APIs

• ListCampaigns (p. 174)• DescribeCampaign (p. 147)• UpdateCampaign (p. 197)• DeleteCampaign (p. 131)

Request Syntax

{ "minProvisionedTPS": number, "name": "string", "solutionVersionArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

minProvisionedTPS (p. 106)

Specifies the requested minimum provisioned transactions (recommendations) per second thatAmazon Personalize will support.

Type: Integer

106

Page 111: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Valid Range: Minimum value of 1.

Required: Yesname (p. 106)

A name for the new campaign. The campaign name must be unique within your account.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: YessolutionVersionArn (p. 106)

The Amazon Resource Name (ARN) of the solution version to deploy.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "campaignArn": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

campaignArn (p. 107)

The Amazon Resource Name (ARN) of the campaign.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400LimitExceededException

The limit on the number of requests per second has been exceeded.

107

Page 112: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

108

Page 113: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateDatasetService: Amazon Personalize

Creates an empty dataset and adds it to the specified dataset group. UseCreateDatasetImportJob (p. 115) to import your training data to a dataset.

There are three types of datasets:

• Interactions• Items• Users

Each dataset type has an associated schema with required field types. Only the Interactions dataset isrequired in order to train a model (also referred to as creating a solution).

A dataset can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

To get the status of the dataset, call DescribeDataset (p. 149).

Related APIs

• CreateDatasetGroup (p. 112)• ListDatasets (p. 182)• DescribeDataset (p. 149)• DeleteDataset (p. 133)

Request Syntax

{ "datasetGroupArn": "string", "datasetType": "string", "name": "string", "schemaArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetGroupArn (p. 109)

The Amazon Resource Name (ARN) of the dataset group to add the dataset to.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

109

Page 114: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

datasetType (p. 109)

The type of dataset.

One of the following (case insensitive) values:• Interactions• Items• Users

Type: String

Length Constraints: Maximum length of 256.

Required: Yesname (p. 109)

The name for the dataset.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: YesschemaArn (p. 109)

The ARN of the schema to associate with the dataset. The schema defines the dataset fields.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "datasetArn": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

datasetArn (p. 110)

The ARN of the dataset.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

110

Page 115: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400LimitExceededException

The limit on the number of requests per second has been exceeded.

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

111

Page 116: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateDatasetGroupService: Amazon Personalize

Creates an empty dataset group. A dataset group contains related datasets that supply data for training amodel. A dataset group can contain at most three datasets, one for each type of dataset:

• Interactions• Items• Users

To train a model (create a solution), a dataset group that contains an Interactions dataset is required.Call CreateDataset (p. 109) to add a dataset to the group.

A dataset group can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING

To get the status of the dataset group, call DescribeDatasetGroup (p. 151). If the status shows asCREATE FAILED, the response includes a failureReason key, which describes why the creation failed.

Note

You must wait until the status of the dataset group is ACTIVE before adding a dataset to thegroup.

You can specify an AWS Key Management Service (KMS) key to encrypt the datasets in the group. If youspecify a KMS key, you must also include an AWS Identity and Access Management (IAM) role that haspermission to access the key.

APIs that require a dataset group ARN in the request

• CreateDataset (p. 109)• CreateEventTracker (p. 118)• CreateSolution (p. 123)

Related APIs

• ListDatasetGroups (p. 177)• DescribeDatasetGroup (p. 151)• DeleteDatasetGroup (p. 135)

Request Syntax

{ "kmsKeyArn": "string", "name": "string", "roleArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

112

Page 117: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

kmsKeyArn (p. 112)

The Amazon Resource Name (ARN) of a KMS key used to encrypt the datasets.

Type: String

Required: Noname (p. 112)

The name for the new dataset group.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: YesroleArn (p. 112)

The ARN of the IAM role that has permissions to access the KMS key. Supplying an IAM role is onlyvalid when also specifying a KMS key.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+

Required: No

Response Syntax

{ "datasetGroupArn": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

datasetGroupArn (p. 113)

The Amazon Resource Name (ARN) of the new dataset group.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

113

Page 118: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HTTP Status Code: 400LimitExceededException

The limit on the number of requests per second has been exceeded.

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

114

Page 119: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateDatasetImportJobService: Amazon Personalize

Creates a job that imports training data from your data source (an Amazon S3 bucket) to an AmazonPersonalize dataset. To allow Amazon Personalize to import the training data, you must specify an AWSIdentity and Access Management (IAM) role that has permission to read from the data source, as AmazonPersonalize makes a copy of your data and processes it in an internal AWS system.

Important

The dataset import job replaces any previous data in the dataset.

Status

A dataset import job can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

To get the status of the import job, call DescribeDatasetImportJob (p. 153), providing the AmazonResource Name (ARN) of the dataset import job. The dataset import is complete when the status shows asACTIVE. If the status shows as CREATE FAILED, the response includes a failureReason key, whichdescribes why the job failed.

Note

Importing takes time. You must wait until the status shows as ACTIVE before training a modelusing the dataset.

Related APIs

• ListDatasetImportJobs (p. 179)• DescribeDatasetImportJob (p. 153)

Request Syntax

{ "datasetArn": "string", "dataSource": { "dataLocation": "string" }, "jobName": "string", "roleArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetArn (p. 115)

The ARN of the dataset that receives the imported data.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

115

Page 120: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Required: YesdataSource (p. 115)

The Amazon S3 bucket that contains the training data to import.

Type: DataSource (p. 244) object

Required: YesjobName (p. 115)

The name for the dataset import job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: YesroleArn (p. 115)

The ARN of the IAM role that has permissions to read from the Amazon S3 data source.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+

Required: Yes

Response Syntax

{ "datasetImportJobArn": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

datasetImportJobArn (p. 116)

The ARN of the dataset import job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

116

Page 121: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HTTP Status Code: 400LimitExceededException

The limit on the number of requests per second has been exceeded.

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

117

Page 122: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateEventTrackerService: Amazon Personalize

Creates an event tracker that you use when sending event data to the specified dataset group using thePutEvents API.

When Amazon Personalize creates an event tracker, it also creates an event-interactions dataset in thedataset group associated with the event tracker. The event-interactions dataset stores the event data fromthe PutEvents call. The contents of this dataset are not available to the user.

Note

Only one event tracker can be associated with a dataset group. You will get an error if you callCreateEventTracker using the same dataset group as an existing event tracker.

When you send event data you include your tracking ID. The tracking ID identifies the customer andauthorizes the customer to send the data.

The event tracker can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

To get the status of the event tracker, call DescribeEventTracker (p. 155).

Note

The event tracker must be in the ACTIVE state before using the tracking ID.

Related APIs

• ListEventTrackers (p. 185)• DescribeEventTracker (p. 155)• DeleteEventTracker (p. 137)

Request Syntax

{ "datasetGroupArn": "string", "name": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetGroupArn (p. 118)

The Amazon Resource Name (ARN) of the dataset group that receives the event data.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

118

Page 123: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

name (p. 118)

The name for the event tracker.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Yes

Response Syntax

{ "eventTrackerArn": "string", "trackingId": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

eventTrackerArn (p. 119)

The ARN of the event tracker.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+trackingId (p. 119)

The ID of the event tracker. Include this ID in requests to the PutEvents API.

Type: String

Length Constraints: Maximum length of 256.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400LimitExceededException

The limit on the number of requests per second has been exceeded.

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

119

Page 124: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

120

Page 125: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateSchemaService: Amazon Personalize

Creates an Amazon Personalize schema from the specified schema string. The schema you create must bein Avro JSON format.

Amazon Personalize recognizes three schema variants. Each schema is associated with a dataset type andhas a set of required field and keywords. You specify a schema when you call CreateDataset (p. 109).

For more information on schemas, see Datasets and Schemas.

Related APIs

• ListSchemas (p. 189)• DescribeSchema (p. 161)• DeleteSchema (p. 139)

Request Syntax

{ "name": "string", "schema": "string"}

Request Parameters

The request accepts the following data in JSON format.

name (p. 121)

The name for the schema.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Yesschema (p. 121)

A schema in Avro JSON format.

Type: String

Length Constraints: Maximum length of 10000.

Required: Yes

Response Syntax

{ "schemaArn": "string"}

121

Page 126: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

schemaArn (p. 121)

The Amazon Resource Name (ARN) of the created schema.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400LimitExceededException

The limit on the number of requests per second has been exceeded.

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

122

Page 127: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateSolutionService: Amazon Personalize

Creates the configuration for training a model. A trained model is known as a solution.After the configuration is created, you train the model (create a solution) by calling theCreateSolutionVersion (p. 128) operation. Every time you call CreateSolutionVersion, a new versionof the solution is created.

After creating a solution version, you check its accuracy by calling GetSolutionMetrics (p. 169). Whenyou are satisfied with the version, you deploy it using CreateCampaign (p. 106). The campaign providesrecommendations to a client through the GetRecommendations API.

To train a model, Amazon Personalize requires training data and a recipe. The training data comesfrom the dataset group that you provide in the request. A recipe specifies the training algorithm and afeature transformation. You can specify one of the predefined recipes provided by Amazon Personalize.Alternatively, you can specify performAutoML and Amazon Personalize will analyze your data and selectthe optimum USER_PERSONALIZATION recipe for you.

Status

A solution can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

To get the status of the solution, call DescribeSolution (p. 163). Wait until the status shows as ACTIVEbefore calling CreateSolutionVersion.

Related APIs

• ListSolutions (p. 191)• CreateSolutionVersion (p. 128)• DescribeSolution (p. 163)• DeleteSolution (p. 141)

• ListSolutionVersions (p. 194)• DescribeSolutionVersion (p. 166)

Request Syntax

{ "datasetGroupArn": "string", "eventType": "string", "name": "string", "performAutoML": boolean, "performHPO": boolean, "recipeArn": "string", "solutionConfig": { "algorithmHyperParameters": { "string" : "string" }, "autoMLConfig": { "metricName": "string", "recipeList": [ "string" ] }, "eventValueThreshold": "string",

123

Page 128: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"featureTransformationParameters": { "string" : "string" }, "hpoConfig": { "algorithmHyperParameterRanges": { "categoricalHyperParameterRanges": [ { "name": "string", "values": [ "string" ] } ], "continuousHyperParameterRanges": [ { "maxValue": number, "minValue": number, "name": "string" } ], "integerHyperParameterRanges": [ { "maxValue": number, "minValue": number, "name": "string" } ] }, "hpoObjective": { "metricName": "string", "metricRegex": "string", "type": "string" }, "hpoResourceConfig": { "maxNumberOfTrainingJobs": "string", "maxParallelTrainingJobs": "string" } } }}

Request ParametersThe request accepts the following data in JSON format.

datasetGroupArn (p. 123)

The Amazon Resource Name (ARN) of the dataset group that provides the training data.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: YeseventType (p. 123)

When your have multiple event types (using an EVENT_TYPE schema field), this parameter specifieswhich event type (for example, 'click' or 'like') is used for training the model.

Type: String

Length Constraints: Maximum length of 256.

Required: No

124

Page 129: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

name (p. 123)

The name for the solution.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: YesperformAutoML (p. 123)

Whether to perform automated machine learning (AutoML). The default is false. For this case, youmust specify recipeArn.

When set to true, Amazon Personalize analyzes your training data and selects the optimalUSER_PERSONALIZATION recipe and hyperparameters. In this case, you must omit recipeArn.Amazon Personalize determines the optimal recipe by running tests with different values for thehyperparameters. AutoML lengthens the training process as compared to selecting a specific recipe.

Type: Boolean

Required: NoperformHPO (p. 123)

Whether to perform hyperparameter optimization (HPO) on the specified or selected recipe. Thedefault is false.

When performing AutoML, this parameter is always true and you should not set it to false.

Type: Boolean

Required: NorecipeArn (p. 123)

The ARN of the recipe to use for model training. Only specified when performAutoML is false.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NosolutionConfig (p. 123)

The configuration to use with the solution. When performAutoML is set to true, Amazon Personalizeonly evaluates the autoMLConfig section of the solution configuration.

Type: SolutionConfig (p. 268) object

Required: No

Response Syntax

{ "solutionArn": "string"}

125

Page 130: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

solutionArn (p. 125)

The ARN of the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400LimitExceededException

The limit on the number of requests per second has been exceeded.

HTTP Status Code: 400ResourceAlreadyExistsException

The specified resource already exists.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python

126

Page 131: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

• AWS SDK for Ruby V3

127

Page 132: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CreateSolutionVersionService: Amazon Personalize

Trains or retrains an active solution. A solution is created using the CreateSolution (p. 123) operation andmust be in the ACTIVE state before calling CreateSolutionVersion. A new version of the solution iscreated every time you call this operation.

Status

A solution version can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

To get the status of the version, call DescribeSolutionVersion (p. 166). Wait until the status shows asACTIVE before calling CreateCampaign.

If the status shows as CREATE FAILED, the response includes a failureReason key, which describeswhy the job failed.

Related APIs

• ListSolutionVersions (p. 194)• DescribeSolutionVersion (p. 166)

• ListSolutions (p. 191)• CreateSolution (p. 123)• DescribeSolution (p. 163)• DeleteSolution (p. 141)

Request Syntax

{ "solutionArn": "string", "trainingMode": "string"}

Request Parameters

The request accepts the following data in JSON format.

solutionArn (p. 128)

The Amazon Resource Name (ARN) of the solution containing the training configuration information.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: YestrainingMode (p. 128)

The scope of training to be performed when creating the solution version. The FULL option trains thesolution version based on the entirety of the input solution's training data, while the UPDATE option

128

Page 133: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

processes only the data that has changed in comparison to the input solution. Choose UPDATE whenyou want to incrementally update your solution version instead of creating an entirely new one.

Important

The UPDATE option can only be used when you already have an active solution versioncreated from the input solution using the FULL option and the input solution was trained withthe HRNN 冷启动配方 (p. 57) recipe.

Type: String

Valid Values: FULL | UPDATE

Required: No

Response Syntax

{ "solutionVersionArn": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

solutionVersionArn (p. 129)

The ARN of the new solution version.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

129

Page 135: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DeleteCampaignService: Amazon Personalize

Removes a campaign by deleting the solution deployment. The solution that the campaign is based onis not deleted and can be redeployed when needed. A deleted campaign can no longer be specified in aGetRecommendations request. For more information on campaigns, see CreateCampaign (p. 106).

Request Syntax

{ "campaignArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

campaignArn (p. 131)

The Amazon Resource Name (ARN) of the campaign to delete.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

131

Page 137: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DeleteDatasetService: Amazon Personalize

Deletes a dataset. You can't delete a dataset if an associated DatasetImportJob or SolutionVersionis in the CREATE PENDING or IN PROGRESS state. For more information on datasets, seeCreateDataset (p. 109).

Request Syntax

{ "datasetArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetArn (p. 133)

The Amazon Resource Name (ARN) of the dataset to delete.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

133

Page 139: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DeleteDatasetGroupService: Amazon Personalize

Deletes a dataset group. Before you delete a dataset group, you must delete the following:

• All associated event trackers.• All associated solutions.• All datasets in the dataset group.

Request Syntax

{ "datasetGroupArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

datasetGroupArn (p. 135)

The ARN of the dataset group to delete.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response ElementsIf the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

135

Page 141: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DeleteEventTrackerService: Amazon Personalize

Deletes the event tracker. Does not delete the event-interactions dataset from the associated datasetgroup. For more information on event trackers, see CreateEventTracker (p. 118).

Request Syntax

{ "eventTrackerArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

eventTrackerArn (p. 137)

The Amazon Resource Name (ARN) of the event tracker to delete.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET

137

Page 143: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DeleteSchemaService: Amazon Personalize

Deletes a schema. Before deleting a schema, you must delete all datasets referencing the schema. Formore information on schemas, see CreateSchema (p. 121).

Request Syntax

{ "schemaArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

schemaArn (p. 139)

The Amazon Resource Name (ARN) of the schema to delete.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET

139

Page 145: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DeleteSolutionService: Amazon Personalize

Deletes all versions of a solution and the Solution object itself. Before deleting a solution, you mustdelete all campaigns based on the solution. To determine what campaigns are using the solution, callListCampaigns (p. 174) and supply the Amazon Resource Name (ARN) of the solution. You can't deletea solution if an associated SolutionVersion is in the CREATE PENDING or IN PROGRESS state. Formore information on solutions, see CreateSolution (p. 123).

Request Syntax

{ "solutionArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

solutionArn (p. 141)

The ARN of the solution to delete.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

141

Page 147: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeAlgorithmService: Amazon Personalize

Describes the given algorithm.

Request Syntax

{ "algorithmArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

algorithmArn (p. 143)

The Amazon Resource Name (ARN) of the algorithm to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "algorithm": { "algorithmArn": "string", "algorithmImage": { "dockerURI": "string", "name": "string" }, "creationDateTime": number, "defaultHyperParameterRanges": { "categoricalHyperParameterRanges": [ { "isTunable": boolean, "name": "string", "values": [ "string" ] } ], "continuousHyperParameterRanges": [ { "isTunable": boolean, "maxValue": number, "minValue": number, "name": "string" } ], "integerHyperParameterRanges": [ { "isTunable": boolean, "maxValue": number, "minValue": number, "name": "string" }

143

Page 148: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

] }, "defaultHyperParameters": { "string" : "string" }, "defaultResourceConfig": { "string" : "string" }, "lastUpdatedDateTime": number, "name": "string", "roleArn": "string", "trainingInputMode": "string" }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

algorithm (p. 143)

A listing of the properties of the algorithm.

Type: Algorithm (p. 209) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

144

Page 149: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeBatchInferenceJobService: Amazon Personalize

Gets the properties of a batch inference job including name, Amazon Resource Name (ARN), status, inputand output configurations, and the ARN of the solution version used to generate the recommendations.

Request Syntax

{ "batchInferenceJobArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

batchInferenceJobArn (p. 145)

The ARN of the batch inference job to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "batchInferenceJob": { "batchInferenceJobArn": "string", "creationDateTime": number, "failureReason": "string", "jobInput": { "s3DataSource": { "kmsKeyArn": "string", "path": "string" } }, "jobName": "string", "jobOutput": { "s3DataDestination": { "kmsKeyArn": "string", "path": "string" } }, "lastUpdatedDateTime": number, "numResults": number, "roleArn": "string", "solutionVersionArn": "string", "status": "string" }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

145

Page 150: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

The following data is returned in JSON format by the service.

batchInferenceJob (p. 145)

Information on the specified batch inference job.

Type: BatchInferenceJob (p. 214) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

146

Page 151: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeCampaignService: Amazon Personalize

Describes the given campaign, including its status.

A campaign can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

When the status is CREATE FAILED, the response includes the failureReason key, which describeswhy.

For more information on campaigns, see CreateCampaign (p. 106).

Request Syntax

{ "campaignArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

campaignArn (p. 147)

The Amazon Resource Name (ARN) of the campaign.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "campaign": { "campaignArn": "string", "creationDateTime": number, "failureReason": "string", "lastUpdatedDateTime": number, "latestCampaignUpdate": { "creationDateTime": number, "failureReason": "string", "lastUpdatedDateTime": number, "minProvisionedTPS": number, "solutionVersionArn": "string", "status": "string" }, "minProvisionedTPS": number, "name": "string", "solutionVersionArn": "string", "status": "string" }

147

Page 152: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

campaign (p. 147)

The properties of the campaign.

Type: Campaign (p. 221) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

148

Page 153: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeDatasetService: Amazon Personalize

Describes the given dataset. For more information on datasets, see CreateDataset (p. 109).

Request Syntax

{ "datasetArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

datasetArn (p. 149)

The Amazon Resource Name (ARN) of the dataset to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "dataset": { "creationDateTime": number, "datasetArn": "string", "datasetGroupArn": "string", "datasetType": "string", "lastUpdatedDateTime": number, "name": "string", "schemaArn": "string", "status": "string" }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

dataset (p. 149)

A listing of the dataset's properties.

Type: Dataset (p. 229) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

149

Page 154: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

150

Page 155: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeDatasetGroupService: Amazon Personalize

Describes the given dataset group. For more information on dataset groups, seeCreateDatasetGroup (p. 112).

Request Syntax

{ "datasetGroupArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetGroupArn (p. 151)

The Amazon Resource Name (ARN) of the dataset group to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "datasetGroup": { "creationDateTime": number, "datasetGroupArn": "string", "failureReason": "string", "kmsKeyArn": "string", "lastUpdatedDateTime": number, "name": "string", "roleArn": "string", "status": "string" }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

datasetGroup (p. 151)

A listing of the dataset group's properties.

Type: DatasetGroup (p. 231) object

151

Page 156: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

152

Page 157: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeDatasetImportJobService: Amazon Personalize

Describes the dataset import job created by CreateDatasetImportJob (p. 115), including the import jobstatus.

Request Syntax

{ "datasetImportJobArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

datasetImportJobArn (p. 153)

The Amazon Resource Name (ARN) of the dataset import job to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "datasetImportJob": { "creationDateTime": number, "datasetArn": "string", "datasetImportJobArn": "string", "dataSource": { "dataLocation": "string" }, "failureReason": "string", "jobName": "string", "lastUpdatedDateTime": number, "roleArn": "string", "status": "string" }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

datasetImportJob (p. 153)

Information about the dataset import job, including the status.

The status is one of the following values:• CREATE PENDING

153

Page 158: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

• CREATE IN_PROGRESS• ACTIVE• CREATE FAILED

Type: DatasetImportJob (p. 235) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

154

Page 159: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeEventTrackerService: Amazon Personalize

Describes an event tracker. The response includes the trackingId and status of the event tracker. Formore information on event trackers, see CreateEventTracker (p. 118).

Request Syntax

{ "eventTrackerArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

eventTrackerArn (p. 155)

The Amazon Resource Name (ARN) of the event tracker to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "eventTracker": { "accountId": "string", "creationDateTime": number, "datasetGroupArn": "string", "eventTrackerArn": "string", "lastUpdatedDateTime": number, "name": "string", "status": "string", "trackingId": "string" }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

eventTracker (p. 155)

An object that describes the event tracker.

Type: EventTracker (p. 249) object

155

Page 160: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

156

Page 161: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeFeatureTransformationService: Amazon Personalize

Describes the given feature transformation.

Request Syntax

{ "featureTransformationArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

featureTransformationArn (p. 157)

The Amazon Resource Name (ARN) of the feature transformation to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "featureTransformation": { "creationDateTime": number, "defaultParameters": { "string" : "string" }, "featureTransformationArn": "string", "lastUpdatedDateTime": number, "name": "string", "status": "string" }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

featureTransformation (p. 157)

A listing of the FeatureTransformation properties.

Type: FeatureTransformation (p. 253) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

157

Page 163: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeRecipeService: Amazon Personalize

Describes a recipe.

A recipe contains three items:

• An algorithm that trains a model.• Hyperparameters that govern the training.• Feature transformation information for modifying the input data before training.

Amazon Personalize provides a set of predefined recipes. You specify a recipe when you create asolution with the CreateSolution (p. 123) API. CreateSolution trains a model by using the algorithmin the specified recipe and a training dataset. The solution, when deployed as a campaign, can providerecommendations using the GetRecommendations API.

Request Syntax

{ "recipeArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

recipeArn (p. 159)

The Amazon Resource Name (ARN) of the recipe to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "recipe": { "algorithmArn": "string", "creationDateTime": number, "description": "string", "featureTransformationArn": "string", "lastUpdatedDateTime": number, "name": "string", "recipeArn": "string", "recipeType": "string", "status": "string" }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

159

Page 164: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

The following data is returned in JSON format by the service.

recipe (p. 159)

An object that describes the recipe.

Type: Recipe (p. 260) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

160

Page 165: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeSchemaService: Amazon Personalize

Describes a schema. For more information on schemas, see CreateSchema (p. 121).

Request Syntax

{ "schemaArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

schemaArn (p. 161)

The Amazon Resource Name (ARN) of the schema to retrieve.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "schema": { "creationDateTime": number, "lastUpdatedDateTime": number, "name": "string", "schema": "string", "schemaArn": "string" }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

schema (p. 161)

The requested schema.

Type: DatasetSchema (p. 239) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

161

Page 166: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

162

Page 167: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeSolutionService: Amazon Personalize

Describes a solution. For more information on solutions, see CreateSolution (p. 123).

Request Syntax

{ "solutionArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

solutionArn (p. 163)

The Amazon Resource Name (ARN) of the solution to describe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "solution": { "autoMLResult": { "bestRecipeArn": "string" }, "creationDateTime": number, "datasetGroupArn": "string", "eventType": "string", "lastUpdatedDateTime": number, "latestSolutionVersion": { "creationDateTime": number, "failureReason": "string", "lastUpdatedDateTime": number, "solutionVersionArn": "string", "status": "string" }, "name": "string", "performAutoML": boolean, "performHPO": boolean, "recipeArn": "string", "solutionArn": "string", "solutionConfig": { "algorithmHyperParameters": { "string" : "string" }, "autoMLConfig": { "metricName": "string", "recipeList": [ "string" ] }, "eventValueThreshold": "string", "featureTransformationParameters": {

163

Page 168: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"string" : "string" }, "hpoConfig": { "algorithmHyperParameterRanges": { "categoricalHyperParameterRanges": [ { "name": "string", "values": [ "string" ] } ], "continuousHyperParameterRanges": [ { "maxValue": number, "minValue": number, "name": "string" } ], "integerHyperParameterRanges": [ { "maxValue": number, "minValue": number, "name": "string" } ] }, "hpoObjective": { "metricName": "string", "metricRegex": "string", "type": "string" }, "hpoResourceConfig": { "maxNumberOfTrainingJobs": "string", "maxParallelTrainingJobs": "string" } } }, "status": "string" }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

solution (p. 163)

An object that describes the solution.

Type: Solution (p. 265) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

164

Page 170: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DescribeSolutionVersionService: Amazon Personalize

Describes a specific version of a solution. For more information on solutions, see CreateSolution (p. 123).

Request Syntax

{ "solutionVersionArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

solutionVersionArn (p. 166)

The Amazon Resource Name (ARN) of the solution version.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "solutionVersion": { "creationDateTime": number, "datasetGroupArn": "string", "eventType": "string", "failureReason": "string", "lastUpdatedDateTime": number, "performAutoML": boolean, "performHPO": boolean, "recipeArn": "string", "solutionArn": "string", "solutionConfig": { "algorithmHyperParameters": { "string" : "string" }, "autoMLConfig": { "metricName": "string", "recipeList": [ "string" ] }, "eventValueThreshold": "string", "featureTransformationParameters": { "string" : "string" }, "hpoConfig": { "algorithmHyperParameterRanges": { "categoricalHyperParameterRanges": [ { "name": "string", "values": [ "string" ] } ],

166

Page 171: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"continuousHyperParameterRanges": [ { "maxValue": number, "minValue": number, "name": "string" } ], "integerHyperParameterRanges": [ { "maxValue": number, "minValue": number, "name": "string" } ] }, "hpoObjective": { "metricName": "string", "metricRegex": "string", "type": "string" }, "hpoResourceConfig": { "maxNumberOfTrainingJobs": "string", "maxParallelTrainingJobs": "string" } } }, "solutionVersionArn": "string", "status": "string", "trainingHours": number, "trainingMode": "string", "tunedHPOParams": { "algorithmHyperParameters": { "string" : "string" } } }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

solutionVersion (p. 166)

The solution version.

Type: SolutionVersion (p. 272) object

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

167

Page 173: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

GetSolutionMetricsService: Amazon Personalize

Gets the metrics for the specified solution version.

Request Syntax

{ "solutionVersionArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

solutionVersionArn (p. 169)

The Amazon Resource Name (ARN) of the solution version for which to get metrics.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Yes

Response Syntax

{ "metrics": { "string" : number }, "solutionVersionArn": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

metrics (p. 169)

The metrics for the solution version.

Type: String to double map

Key Length Constraints: Maximum length of 256.solutionVersionArn (p. 169)

The same solution version ARN as specified in the request.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

169

Page 174: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

170

Page 175: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListBatchInferenceJobsService: Amazon Personalize

Gets a list of the batch inference jobs that have been performed off of a solution version.

Request Syntax

{ "maxResults": number, "nextToken": "string", "solutionVersionArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

maxResults (p. 171)

The maximum number of batch inference job results to return in each page. The default value is 100.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 171)

The token to request the next page of results.

Type: String

Length Constraints: Maximum length of 1300.

Required: NosolutionVersionArn (p. 171)

The Amazon Resource Name (ARN) of the solution version from which the batch inference jobs werecreated.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

Response Syntax

{ "batchInferenceJobs": [ { "batchInferenceJobArn": "string", "creationDateTime": number, "failureReason": "string", "jobName": "string", "lastUpdatedDateTime": number,

171

Page 176: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"solutionVersionArn": "string", "status": "string" } ], "nextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

batchInferenceJobs (p. 171)

A list containing information on each job that is returned.

Type: Array of BatchInferenceJobSummary (p. 219) objects

Array Members: Maximum number of 100 items.nextToken (p. 171)

The token to use to retreive the next page of results. The value is null when there are no more resultsto return.

Type: String

Length Constraints: Maximum length of 1300.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

172

Page 177: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

173

Page 178: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListCampaignsService: Amazon Personalize

Returns a list of campaigns that use the given solution. When a solution is not specified, all the campaignsassociated with the account are listed. The response provides the properties for each campaign, includingthe Amazon Resource Name (ARN). For more information on campaigns, see CreateCampaign (p. 106).

Request Syntax

{ "maxResults": number, "nextToken": "string", "solutionArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

maxResults (p. 174)

The maximum number of campaigns to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 174)

A token returned from the previous call to ListCampaigns for getting the next set of campaigns (ifthey exist).

Type: String

Length Constraints: Maximum length of 1300.

Required: NosolutionArn (p. 174)

The Amazon Resource Name (ARN) of the solution to list the campaigns for. When a solution is notspecified, all the campaigns associated with the account are listed.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

Response Syntax

{ "campaigns": [ { "campaignArn": "string", "creationDateTime": number,

174

Page 179: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"failureReason": "string", "lastUpdatedDateTime": number, "name": "string", "status": "string" } ], "nextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

campaigns (p. 174)

A list of the campaigns.

Type: Array of CampaignSummary (p. 223) objects

Array Members: Maximum number of 100 items.nextToken (p. 174)

A token for getting the next set of campaigns (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

175

Page 180: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

176

Page 181: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListDatasetGroupsService: Amazon Personalize

Returns a list of dataset groups. The response provides the properties for each dataset group,including the Amazon Resource Name (ARN). For more information on dataset groups, seeCreateDatasetGroup (p. 112).

Request Syntax

{ "maxResults": number, "nextToken": "string"}

Request Parameters

The request accepts the following data in JSON format.

maxResults (p. 177)

The maximum number of dataset groups to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 177)

A token returned from the previous call to ListDatasetGroups for getting the next set of datasetgroups (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Required: No

Response Syntax

{ "datasetGroups": [ { "creationDateTime": number, "datasetGroupArn": "string", "failureReason": "string", "lastUpdatedDateTime": number, "name": "string", "status": "string" } ], "nextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

177

Page 182: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

The following data is returned in JSON format by the service.

datasetGroups (p. 177)

The list of your dataset groups.

Type: Array of DatasetGroupSummary (p. 233) objects

Array Members: Maximum number of 100 items.nextToken (p. 177)

A token for getting the next set of dataset groups (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Errors

InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

178

Page 183: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListDatasetImportJobsService: Amazon Personalize

Returns a list of dataset import jobs that use the given dataset. When a dataset is not specified, all thedataset import jobs associated with the account are listed. The response provides the properties for eachdataset import job, including the Amazon Resource Name (ARN). For more information on dataset importjobs, see CreateDatasetImportJob (p. 115). For more information on datasets, see CreateDataset (p. 109).

Request Syntax

{ "datasetArn": "string", "maxResults": number, "nextToken": "string"}

Request ParametersThe request accepts the following data in JSON format.

datasetArn (p. 179)

The Amazon Resource Name (ARN) of the dataset to list the dataset import jobs for.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NomaxResults (p. 179)

The maximum number of dataset import jobs to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 179)

A token returned from the previous call to ListDatasetImportJobs for getting the next set ofdataset import jobs (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Required: No

Response Syntax

{ "datasetImportJobs": [ { "creationDateTime": number, "datasetImportJobArn": "string",

179

Page 184: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"failureReason": "string", "jobName": "string", "lastUpdatedDateTime": number, "status": "string" } ], "nextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

datasetImportJobs (p. 179)

The list of dataset import jobs.

Type: Array of DatasetImportJobSummary (p. 237) objects

Array Members: Maximum number of 100 items.nextToken (p. 179)

A token for getting the next set of dataset import jobs (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

180

Page 185: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

181

Page 186: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListDatasetsService: Amazon Personalize

Returns the list of datasets contained in the given dataset group. The response provides the propertiesfor each dataset, including the Amazon Resource Name (ARN). For more information on datasets, seeCreateDataset (p. 109).

Request Syntax

{ "datasetGroupArn": "string", "maxResults": number, "nextToken": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetGroupArn (p. 182)

The Amazon Resource Name (ARN) of the dataset group that contains the datasets to list.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NomaxResults (p. 182)

The maximum number of datasets to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 182)

A token returned from the previous call to ListDatasetImportJobs for getting the next set ofdataset import jobs (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Required: No

Response Syntax

{ "datasets": [ { "creationDateTime": number, "datasetArn": "string", "datasetType": "string",

182

Page 187: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"lastUpdatedDateTime": number, "name": "string", "status": "string" } ], "nextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

datasets (p. 182)

An array of Dataset objects. Each object provides metadata information.

Type: Array of DatasetSummary (p. 242) objects

Array Members: Maximum number of 100 items.nextToken (p. 182)

A token for getting the next set of datasets (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

183

Page 188: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

184

Page 189: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListEventTrackersService: Amazon Personalize

Returns the list of event trackers associated with the account. The response provides the properties foreach event tracker, including the Amazon Resource Name (ARN) and tracking ID. For more information onevent trackers, see CreateEventTracker (p. 118).

Request Syntax

{ "datasetGroupArn": "string", "maxResults": number, "nextToken": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetGroupArn (p. 185)

The ARN of a dataset group used to filter the response.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NomaxResults (p. 185)

The maximum number of event trackers to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 185)

A token returned from the previous call to ListEventTrackers for getting the next set of eventtrackers (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Required: No

Response Syntax

{ "eventTrackers": [ { "creationDateTime": number, "eventTrackerArn": "string", "lastUpdatedDateTime": number,

185

Page 190: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"name": "string", "status": "string" } ], "nextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

eventTrackers (p. 185)

A list of event trackers.

Type: Array of EventTrackerSummary (p. 251) objects

Array Members: Maximum number of 100 items.nextToken (p. 185)

A token for getting the next set of event trackers (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

186

Page 191: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListRecipesService: Amazon Personalize

Returns a list of available recipes. The response provides the properties for each recipe, including therecipe's Amazon Resource Name (ARN).

Request Syntax

{ "maxResults": number, "nextToken": "string", "recipeProvider": "string"}

Request Parameters

The request accepts the following data in JSON format.

maxResults (p. 187)

The maximum number of recipes to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 187)

A token returned from the previous call to ListRecipes for getting the next set of recipes (if theyexist).

Type: String

Length Constraints: Maximum length of 1300.

Required: NorecipeProvider (p. 187)

The default is SERVICE.

Type: String

Valid Values: SERVICE

Required: No

Response Syntax

{ "nextToken": "string", "recipes": [ { "creationDateTime": number, "lastUpdatedDateTime": number, "name": "string", "recipeArn": "string", "status": "string"

187

Page 192: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

} ]}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

nextToken (p. 187)

A token for getting the next set of recipes.

Type: String

Length Constraints: Maximum length of 1300.recipes (p. 187)

The list of available recipes.

Type: Array of RecipeSummary (p. 262) objects

Array Members: Maximum number of 100 items.

Errors

InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

188

Page 193: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListSchemasService: Amazon Personalize

Returns the list of schemas associated with the account. The response provides the properties foreach schema, including the Amazon Resource Name (ARN). For more information on schemas, seeCreateSchema (p. 121).

Request Syntax

{ "maxResults": number, "nextToken": "string"}

Request Parameters

The request accepts the following data in JSON format.

maxResults (p. 189)

The maximum number of schemas to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 189)

A token returned from the previous call to ListSchemas for getting the next set of schemas (if theyexist).

Type: String

Length Constraints: Maximum length of 1300.

Required: No

Response Syntax

{ "nextToken": "string", "schemas": [ { "creationDateTime": number, "lastUpdatedDateTime": number, "name": "string", "schemaArn": "string" } ]}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

189

Page 194: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

nextToken (p. 189)

A token used to get the next set of schemas (if they exist).

Type: String

Length Constraints: Maximum length of 1300.schemas (p. 189)

A list of schemas.

Type: Array of DatasetSchemaSummary (p. 241) objects

Array Members: Maximum number of 100 items.

Errors

InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

190

Page 195: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListSolutionsService: Amazon Personalize

Returns a list of solutions that use the given dataset group. When a dataset group is not specified,all the solutions associated with the account are listed. The response provides the properties foreach solution, including the Amazon Resource Name (ARN). For more information on solutions, seeCreateSolution (p. 123).

Request Syntax

{ "datasetGroupArn": "string", "maxResults": number, "nextToken": "string"}

Request Parameters

The request accepts the following data in JSON format.

datasetGroupArn (p. 191)

The Amazon Resource Name (ARN) of the dataset group.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NomaxResults (p. 191)

The maximum number of solutions to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 191)

A token returned from the previous call to ListSolutions for getting the next set of solutions (if theyexist).

Type: String

Length Constraints: Maximum length of 1300.

Required: No

Response Syntax

{ "nextToken": "string", "solutions": [ {

191

Page 196: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"creationDateTime": number, "lastUpdatedDateTime": number, "name": "string", "solutionArn": "string", "status": "string" } ]}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

nextToken (p. 191)

A token for getting the next set of solutions (if they exist).

Type: String

Length Constraints: Maximum length of 1300.solutions (p. 191)

A list of the current solutions.

Type: Array of SolutionSummary (p. 270) objects

Array Members: Maximum number of 100 items.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

192

Page 197: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

193

Page 198: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ListSolutionVersionsService: Amazon Personalize

Returns a list of solution versions for the given solution. When a solution is not specified, all thesolution versions associated with the account are listed. The response provides the properties for eachsolution version, including the Amazon Resource Name (ARN). For more information on solutions, seeCreateSolution (p. 123).

Request Syntax

{ "maxResults": number, "nextToken": "string", "solutionArn": "string"}

Request ParametersThe request accepts the following data in JSON format.

maxResults (p. 194)

The maximum number of solution versions to return.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 100.

Required: NonextToken (p. 194)

A token returned from the previous call to ListSolutionVersions for getting the next set of solutionversions (if they exist).

Type: String

Length Constraints: Maximum length of 1300.

Required: NosolutionArn (p. 194)

The Amazon Resource Name (ARN) of the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

Response Syntax

{ "nextToken": "string", "solutionVersions": [ { "creationDateTime": number,

194

Page 199: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

"failureReason": "string", "lastUpdatedDateTime": number, "solutionVersionArn": "string", "status": "string" } ]}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

nextToken (p. 194)

A token for getting the next set of solution versions (if they exist).

Type: String

Length Constraints: Maximum length of 1300.solutionVersions (p. 194)

A list of solution versions describing the version properties.

Type: Array of SolutionVersionSummary (p. 275) objects

Array Members: Maximum number of 100 items.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400InvalidNextTokenException

The token is not valid.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript

195

Page 201: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

UpdateCampaignService: Amazon Personalize

Updates a campaign by either deploying a new solution or changing the value of the campaign'sminProvisionedTPS parameter.

To update a campaign, the campaign status must be ACTIVE or CREATE FAILED. Check the campaignstatus using the DescribeCampaign (p. 147) API.

Note

You must wait until the status of the updated campaign is ACTIVE before asking the campaignfor recommendations.

For more information on campaigns, see CreateCampaign (p. 106).

Request Syntax

{ "campaignArn": "string", "minProvisionedTPS": number, "solutionVersionArn": "string"}

Request Parameters

The request accepts the following data in JSON format.

campaignArn (p. 197)

The Amazon Resource Name (ARN) of the campaign.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: YesminProvisionedTPS (p. 197)

Specifies the requested minimum provisioned transactions (recommendations) per second thatAmazon Personalize will support.

Type: Integer

Valid Range: Minimum value of 1.

Required: NosolutionVersionArn (p. 197)

The ARN of a new solution version to deploy.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

197

Page 202: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Required: No

Response Syntax

{ "campaignArn": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

campaignArn (p. 198)

The same campaign ARN as given in the request.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceInUseException

The specified resource is in use.

HTTP Status Code: 400ResourceNotFoundException

Could not find the specified resource.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python

198

Page 203: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Events

• AWS SDK for Ruby V3

Amazon Personalize EventsThe following actions are supported by Amazon Personalize Events:

• PutEvents (p. 200)

199

Page 204: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Events

PutEventsService: Amazon Personalize Events

Records user interaction event data.

Request Syntax

POST /events HTTP/1.1Content-type: application/json

{ "eventList": [ { "eventId": "string", "eventType": "string", "properties": "string", "sentAt": number } ], "sessionId": "string", "trackingId": "string", "userId": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

eventList (p. 200)

A list of event data from the session.

Type: Array of Event (p. 278) objects

Array Members: Minimum number of 1 item. Maximum number of 10 items.

Required: YessessionId (p. 200)

The session ID associated with the user's visit.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: YestrackingId (p. 200)

The tracking ID for the event. The ID is generated by a call to the CreateEventTracker API.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: Yes

200

Page 205: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Runtime

userId (p. 200)

The user associated with the event.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: No

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

Amazon Personalize RuntimeThe following actions are supported by Amazon Personalize Runtime:

• GetPersonalizedRanking (p. 202)• GetRecommendations (p. 204)

201

Page 206: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Runtime

GetPersonalizedRankingService: Amazon Personalize Runtime

Re-ranks a list of recommended items for the given user. The first item in the list is deemed the most likelyitem to be of interest to the user.

Note

The solution backing the campaign must have been created using a recipe of typePERSONALIZED_RANKING.

Request Syntax

POST /personalize-ranking HTTP/1.1Content-type: application/json

{ "campaignArn": "string", "inputList": [ "string" ], "userId": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

campaignArn (p. 202)

The Amazon Resource Name (ARN) of the campaign to use for generating the personalized ranking.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: YesinputList (p. 202)

A list of items (itemId's) to rank. If an item was not included in the training dataset, the item isappended to the end of the reranked list. The maximum is 500.

Type: Array of strings

Length Constraints: Maximum length of 256.

Required: YesuserId (p. 202)

The user for which you want the campaign to provide a personalized ranking.

Type: String

Length Constraints: Maximum length of 256.

Required: Yes

202

Page 207: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Runtime

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "personalizedRanking": [ { "itemId": "string" } ]}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

personalizedRanking (p. 203)

A list of items in order of most likely interest to the user. The maximum is 500.

Type: Array of PredictedItem (p. 280) objects

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

The specified resource does not exist.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

203

Page 208: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Runtime

GetRecommendationsService: Amazon Personalize Runtime

Returns a list of recommended items. The required input depends on the recipe type used to create thesolution backing the campaign, as follows:

• RELATED_ITEMS - itemId required, userId not used• USER_PERSONALIZATION - itemId optional, userId required

Note

Campaigns that are backed by a solution created using a recipe of typePERSONALIZED_RANKING use the GetPersonalizedRanking (p. 202) API.

Request Syntax

POST /recommendations HTTP/1.1Content-type: application/json

{ "campaignArn": "string", "itemId": "string", "numResults": number, "userId": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

campaignArn (p. 204)

The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: YesitemId (p. 204)

The item ID to provide recommendations for.

Required for RELATED_ITEMS recipe type.

Type: String

Length Constraints: Maximum length of 256.

Required: No

204

Page 209: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Runtime

numResults (p. 204)

The number of results to return. The default is 25. The maximum is 500.

Type: Integer

Valid Range: Minimum value of 0.

Required: NouserId (p. 204)

The user ID to provide recommendations for.

Required for USER_PERSONALIZATION recipe type.

Type: String

Length Constraints: Maximum length of 256.

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "itemList": [ { "itemId": "string" } ]}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

itemList (p. 205)

A list of recommendations sorted in ascending order by prediction score. There can be a maximum of500 items in the list.

Type: Array of PredictedItem (p. 280) objects

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400ResourceNotFoundException

The specified resource does not exist.

HTTP Status Code: 404

205

Page 210: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Data Types

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

Data TypesThe following data types are supported by Amazon Personalize:

• Algorithm (p. 209)• AlgorithmImage (p. 211)• AutoMLConfig (p. 212)• AutoMLResult (p. 213)• BatchInferenceJob (p. 214)• BatchInferenceJobInput (p. 217)• BatchInferenceJobOutput (p. 218)• BatchInferenceJobSummary (p. 219)• Campaign (p. 221)• CampaignSummary (p. 223)• CampaignUpdateSummary (p. 225)• CategoricalHyperParameterRange (p. 227)• ContinuousHyperParameterRange (p. 228)• Dataset (p. 229)• DatasetGroup (p. 231)• DatasetGroupSummary (p. 233)• DatasetImportJob (p. 235)• DatasetImportJobSummary (p. 237)• DatasetSchema (p. 239)• DatasetSchemaSummary (p. 241)• DatasetSummary (p. 242)• DataSource (p. 244)• DefaultCategoricalHyperParameterRange (p. 245)• DefaultContinuousHyperParameterRange (p. 246)• DefaultHyperParameterRanges (p. 247)• DefaultIntegerHyperParameterRange (p. 248)• EventTracker (p. 249)• EventTrackerSummary (p. 251)

206

Page 211: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

• FeatureTransformation (p. 253)• HPOConfig (p. 255)• HPOObjective (p. 256)• HPOResourceConfig (p. 257)• HyperParameterRanges (p. 258)• IntegerHyperParameterRange (p. 259)• Recipe (p. 260)• RecipeSummary (p. 262)• S3DataConfig (p. 264)• Solution (p. 265)• SolutionConfig (p. 268)• SolutionSummary (p. 270)• SolutionVersion (p. 272)• SolutionVersionSummary (p. 275)• TunedHPOParams (p. 277)

The following data types are supported by Amazon Personalize Events:

• Event (p. 278)

The following data types are supported by Amazon Personalize Runtime:

• PredictedItem (p. 280)

Amazon PersonalizeThe following data types are supported by Amazon Personalize:

• Algorithm (p. 209)• AlgorithmImage (p. 211)• AutoMLConfig (p. 212)• AutoMLResult (p. 213)• BatchInferenceJob (p. 214)• BatchInferenceJobInput (p. 217)• BatchInferenceJobOutput (p. 218)• BatchInferenceJobSummary (p. 219)• Campaign (p. 221)• CampaignSummary (p. 223)• CampaignUpdateSummary (p. 225)• CategoricalHyperParameterRange (p. 227)• ContinuousHyperParameterRange (p. 228)• Dataset (p. 229)• DatasetGroup (p. 231)• DatasetGroupSummary (p. 233)• DatasetImportJob (p. 235)• DatasetImportJobSummary (p. 237)• DatasetSchema (p. 239)

207

Page 212: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

• DatasetSchemaSummary (p. 241)• DatasetSummary (p. 242)• DataSource (p. 244)• DefaultCategoricalHyperParameterRange (p. 245)• DefaultContinuousHyperParameterRange (p. 246)• DefaultHyperParameterRanges (p. 247)• DefaultIntegerHyperParameterRange (p. 248)• EventTracker (p. 249)• EventTrackerSummary (p. 251)• FeatureTransformation (p. 253)• HPOConfig (p. 255)• HPOObjective (p. 256)• HPOResourceConfig (p. 257)• HyperParameterRanges (p. 258)• IntegerHyperParameterRange (p. 259)• Recipe (p. 260)• RecipeSummary (p. 262)• S3DataConfig (p. 264)• Solution (p. 265)• SolutionConfig (p. 268)• SolutionSummary (p. 270)• SolutionVersion (p. 272)• SolutionVersionSummary (p. 275)• TunedHPOParams (p. 277)

208

Page 213: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

AlgorithmService: Amazon Personalize

Describes a custom algorithm.

Contents

algorithmArn

The Amazon Resource Name (ARN) of the algorithm.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NoalgorithmImage

The URI of the Docker container for the algorithm image.

Type: AlgorithmImage (p. 211) object

Required: NocreationDateTime

The date and time (in Unix time) that the algorithm was created.

Type: Timestamp

Required: NodefaultHyperParameterRanges

Specifies the default hyperparameters, their ranges, and whether they are tunable. A tunablehyperparameter can have its value determined during hyperparameter optimization (HPO).

Type: DefaultHyperParameterRanges (p. 247) object

Required: NodefaultHyperParameters

Specifies the default hyperparameters.

Type: String to string map

Key Length Constraints: Maximum length of 256.

Value Length Constraints: Maximum length of 1000.

Required: NodefaultResourceConfig

Specifies the default maximum number of training jobs and parallel training jobs.

Type: String to string map

Key Length Constraints: Maximum length of 256.

Value Length Constraints: Maximum length of 1000.

209

Page 214: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the algorithm was last updated.

Type: Timestamp

Required: Noname

The name of the algorithm.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NoroleArn

The Amazon Resource Name (ARN) of the role.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NotrainingInputMode

The training input mode.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

210

Page 215: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

AlgorithmImageService: Amazon Personalize

Describes an algorithm image.

Contents

dockerURI

The URI of the Docker container for the algorithm image.

Type: String

Length Constraints: Maximum length of 256.

Required: Yesname

The name of the algorithm image.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

211

Page 216: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

AutoMLConfigService: Amazon Personalize

When the solution performs AutoML (performAutoML is true in CreateSolution (p. 123)), AmazonPersonalize determines which recipe, from the specified list, optimizes the given metric. AmazonPersonalize then uses that recipe for the solution.

Contents

metricName

The metric to optimize.

Type: String

Length Constraints: Maximum length of 256.

Required: NorecipeList

The list of candidate recipes.

Type: Array of strings

Array Members: Maximum number of 100 items.

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

212

Page 217: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

AutoMLResultService: Amazon Personalize

When the solution performs AutoML (performAutoML is true in CreateSolution (p. 123)), specifies therecipe that best optimized the specified metric.

Contents

bestRecipeArn

The Amazon Resource Name (ARN) of the best recipe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

213

Page 218: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

BatchInferenceJobService: Amazon Personalize

Contains information on a batch inference job.

Contents

batchInferenceJobArn

The Amazon Resource Name (ARN) of the batch inference job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NocreationDateTime

The time at which the batch inference job was created.

Type: Timestamp

Required: NofailureReason

If the batch inference job failed, the reason for the failure.

Type: String

Required: NojobInput

The Amazon S3 path that leads to the input data used to generate the batch inference job.

Type: BatchInferenceJobInput (p. 217) object

Required: NojobName

The name of the batch inference job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NojobOutput

The Amazon S3 bucket that contains the output data generated by the batch inference job.

Type: BatchInferenceJobOutput (p. 218) object

Required: NolastUpdatedDateTime

The time at which the batch inference job was last updated.

214

Page 219: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: Timestamp

Required: NonumResults

The number of recommendations generated by the batch inference job. This number includes the errormessages generated for failed input records.

Type: Integer

Required: NoroleArn

The ARN of the Amazon Identity and Access Management (IAM) role that requested the batchinference job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+

Required: NosolutionVersionArn

The Amazon Resource Name (ARN) of the solution version from which the batch inference job wascreated.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the batch inference job. The status is one of the following values:• PENDING• IN PROGRESS• ACTIVE• CREATE FAILED

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

215

Page 220: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

216

Page 221: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

BatchInferenceJobInputService: Amazon Personalize

The input configuration of a batch inference job.

Contents

s3DataSource

The URI of the Amazon S3 location that contains your input data. The Amazon S3 bucket must be inthe same region as the API endpoint you are calling.

Type: S3DataConfig (p. 264) object

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

217

Page 222: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

BatchInferenceJobOutputService: Amazon Personalize

The output configuration parameters of a batch inference job.

Contents

s3DataDestination

Information on the Amazon S3 bucket in which the batch inference job's output is stored.

Type: S3DataConfig (p. 264) object

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

218

Page 223: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

BatchInferenceJobSummaryService: Amazon Personalize

A truncated version of the BatchInferenceJob (p. 214) datatype. The ListBatchInferenceJobs (p. 171)operation returns a list of batch inference job summaries.

Contents

batchInferenceJobArn

The Amazon Resource Name (ARN) of the batch inference job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NocreationDateTime

The time at which the batch inference job was created.

Type: Timestamp

Required: NofailureReason

If the batch inference job failed, the reason for the failure.

Type: String

Required: NojobName

The name of the batch inference job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NolastUpdatedDateTime

The time at which the batch inference job was last updated.

Type: Timestamp

Required: NosolutionVersionArn

The ARN of the solution version used by the batch inference job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

219

Page 224: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Required: Nostatus

The status of the batch inference job. The status is one of the following values:• PENDING• IN PROGRESS• ACTIVE• CREATE FAILED

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

220

Page 225: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CampaignService: Amazon Personalize

Describes a deployed solution version, otherwise known as a campaign. For more information oncampaigns, see CreateCampaign (p. 106).

Contents

campaignArn

The Amazon Resource Name (ARN) of the campaign.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NocreationDateTime

The date and time (in Unix format) that the campaign was created.

Type: Timestamp

Required: NofailureReason

If a campaign fails, the reason behind the failure.

Type: String

Required: NolastUpdatedDateTime

The date and time (in Unix format) that the campaign was last updated.

Type: Timestamp

Required: NolatestCampaignUpdate

Provides a summary of the properties of a campaign update. For a complete listing, call theDescribeCampaign (p. 147) API.

Type: CampaignUpdateSummary (p. 225) object

Required: NominProvisionedTPS

Specifies the requested minimum provisioned transactions (recommendations) per second.

Type: Integer

Valid Range: Minimum value of 1.

Required: Noname

The name of the campaign.

221

Page 226: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NosolutionVersionArn

The Amazon Resource Name (ARN) of a specific version of the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the campaign.

A campaign can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

222

Page 227: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CampaignSummaryService: Amazon Personalize

Provides a summary of the properties of a campaign. For a complete listing, call theDescribeCampaign (p. 147) API.

Contents

campaignArn

The Amazon Resource Name (ARN) of the campaign.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NocreationDateTime

The date and time (in Unix time) that the campaign was created.

Type: Timestamp

Required: NofailureReason

If a campaign fails, the reason behind the failure.

Type: String

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the campaign was last updated.

Type: Timestamp

Required: Noname

The name of the campaign.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Nostatus

The status of the campaign.

A campaign can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

223

Page 228: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

224

Page 229: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CampaignUpdateSummaryService: Amazon Personalize

Provides a summary of the properties of a campaign update. For a complete listing, call theDescribeCampaign (p. 147) API.

Contents

creationDateTime

The date and time (in Unix time) that the campaign update was created.

Type: Timestamp

Required: NofailureReason

If a campaign update fails, the reason behind the failure.

Type: String

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the campaign update was last updated.

Type: Timestamp

Required: NominProvisionedTPS

Specifies the requested minimum provisioned transactions (recommendations) per second thatAmazon Personalize will support.

Type: Integer

Valid Range: Minimum value of 1.

Required: NosolutionVersionArn

The Amazon Resource Name (ARN) of the deployed solution version.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the campaign update.

A campaign update can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

Type: String

225

Page 230: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

226

Page 231: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

CategoricalHyperParameterRangeService: Amazon Personalize

Provides the name and range of a categorical hyperparameter.

Contents

name

The name of the hyperparameter.

Type: String

Length Constraints: Maximum length of 256.

Required: Novalues

A list of the categories for the hyperparameter.

Type: Array of strings

Array Members: Maximum number of 100 items.

Length Constraints: Maximum length of 1000.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

227

Page 232: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

ContinuousHyperParameterRangeService: Amazon Personalize

Provides the name and range of a continuous hyperparameter.

Contents

maxValue

The maximum allowable value for the hyperparameter.

Type: Double

Valid Range: Minimum value of -1000000.

Required: NominValue

The minimum allowable value for the hyperparameter.

Type: Double

Valid Range: Minimum value of -1000000.

Required: Noname

The name of the hyperparameter.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

228

Page 233: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetService: Amazon Personalize

Provides metadata for a dataset.

Contents

creationDateTime

The creation date and time (in Unix time) of the dataset.

Type: Timestamp

Required: NodatasetArn

The Amazon Resource Name (ARN) of the dataset that you want metadata for.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NodatasetGroupArn

The Amazon Resource Name (ARN) of the dataset group.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NodatasetType

One of the following values:• Interactions• Items• Users

Type: String

Length Constraints: Maximum length of 256.

Required: NolastUpdatedDateTime

A time stamp that shows when the dataset was updated.

Type: Timestamp

Required: Noname

The name of the dataset.

229

Page 234: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NoschemaArn

The ARN of the associated schema.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the dataset.

A dataset can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

230

Page 235: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetGroupService: Amazon Personalize

A dataset group is a collection of related datasets (Interactions, User, and Item). You create a datasetgroup by calling CreateDatasetGroup (p. 112). You then create a dataset and add it to a dataset groupby calling CreateDataset (p. 109). The dataset group is used to create and train a solution by callingCreateSolution (p. 123). A dataset group can contain only one of each type of dataset.

You can specify an AWS Key Management Service (KMS) key to encrypt the datasets in the group.

Contents

creationDateTime

The creation date and time (in Unix time) of the dataset group.

Type: Timestamp

Required: NodatasetGroupArn

The Amazon Resource Name (ARN) of the dataset group.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NofailureReason

If creating a dataset group fails, provides the reason why.

Type: String

Required: NokmsKeyArn

The Amazon Resource Name (ARN) of the KMS key used to encrypt the datasets.

Type: String

Required: NolastUpdatedDateTime

The last update date and time (in Unix time) of the dataset group.

Type: Timestamp

Required: Noname

The name of the dataset group.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

231

Page 236: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Required: NoroleArn

The ARN of the IAM role that has permissions to create the dataset group.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+

Required: Nostatus

The current status of the dataset group.

A dataset group can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

232

Page 237: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetGroupSummaryService: Amazon Personalize

Provides a summary of the properties of a dataset group. For a complete listing, call theDescribeDatasetGroup (p. 151) API.

Contents

creationDateTime

The date and time (in Unix time) that the dataset group was created.

Type: Timestamp

Required: NodatasetGroupArn

The Amazon Resource Name (ARN) of the dataset group.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NofailureReason

If creating a dataset group fails, the reason behind the failure.

Type: String

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the dataset group was last updated.

Type: Timestamp

Required: Noname

The name of the dataset group.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Nostatus

The status of the dataset group.

A dataset group can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING

233

Page 238: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

234

Page 239: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetImportJobService: Amazon Personalize

Describes a job that imports training data from a data source (Amazon S3 bucket) to an AmazonPersonalize dataset. For more information, see CreateDatasetImportJob (p. 115).

A dataset import job can be in one of the following states:

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

Contents

creationDateTime

The creation date and time (in Unix time) of the dataset import job.

Type: Timestamp

Required: NodatasetArn

The Amazon Resource Name (ARN) of the dataset that receives the imported data.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NodatasetImportJobArn

The ARN of the dataset import job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NodataSource

The Amazon S3 bucket that contains the training data to import.

Type: DataSource (p. 244) object

Required: NofailureReason

If a dataset import job fails, provides the reason why.

Type: String

Required: NojobName

The name of the import job.

235

Page 240: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NolastUpdatedDateTime

The date and time (in Unix time) the dataset was last updated.

Type: Timestamp

Required: NoroleArn

The ARN of the AWS Identity and Access Management (IAM) role that has permissions to read fromthe Amazon S3 data source.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the dataset import job.

A dataset import job can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

236

Page 241: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetImportJobSummaryService: Amazon Personalize

Provides a summary of the properties of a dataset import job. For a complete listing, call theDescribeDatasetImportJob (p. 153) API.

Contents

creationDateTime

The date and time (in Unix time) that the dataset import job was created.

Type: Timestamp

Required: NodatasetImportJobArn

The Amazon Resource Name (ARN) of the dataset import job.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NofailureReason

If a dataset import job fails, the reason behind the failure.

Type: String

Required: NojobName

The name of the dataset import job.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the dataset was last updated.

Type: Timestamp

Required: Nostatus

The status of the dataset import job.

A dataset import job can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

Type: String

237

Page 242: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

238

Page 243: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetSchemaService: Amazon Personalize

Describes the schema for a dataset. For more information on schemas, see CreateSchema (p. 121).

Contents

creationDateTime

The date and time (in Unix time) that the schema was created.

Type: Timestamp

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the schema was last updated.

Type: Timestamp

Required: Noname

The name of the schema.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Noschema

The schema.

Type: String

Length Constraints: Maximum length of 10000.

Required: NoschemaArn

The Amazon Resource Name (ARN) of the schema.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++

239

Page 245: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetSchemaSummaryService: Amazon Personalize

Provides a summary of the properties of a dataset schema. For a complete listing, call theDescribeSchema (p. 161) API.

Contents

creationDateTime

The date and time (in Unix time) that the schema was created.

Type: Timestamp

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the schema was last updated.

Type: Timestamp

Required: Noname

The name of the schema.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NoschemaArn

The Amazon Resource Name (ARN) of the schema.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

241

Page 246: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DatasetSummaryService: Amazon Personalize

Provides a summary of the properties of a dataset. For a complete listing, call the DescribeDataset (p. 149)API.

Contents

creationDateTime

The date and time (in Unix time) that the dataset was created.

Type: Timestamp

Required: NodatasetArn

The Amazon Resource Name (ARN) of the dataset.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NodatasetType

The dataset type. One of the following values:• Interactions• Items• Users• Event-Interactions

Type: String

Length Constraints: Maximum length of 256.

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the dataset was last updated.

Type: Timestamp

Required: Noname

The name of the dataset.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: No

242

Page 247: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

status

The status of the dataset.

A dataset can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

243

Page 248: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DataSourceService: Amazon Personalize

Describes the data source that contains the data to upload to a dataset.

Contents

dataLocation

The path to the Amazon S3 bucket where the data that you want to upload to your dataset is stored.For example:

s3://bucket-name/training-data.csv

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

244

Page 249: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DefaultCategoricalHyperParameterRangeService: Amazon Personalize

Provides the name and default range of a categorical hyperparameter and whether the hyperparameteris tunable. A tunable hyperparameter can have its value determined during hyperparameter optimization(HPO).

Contents

isTunable

Whether the hyperparameter is tunable.

Type: Boolean

Required: Noname

The name of the hyperparameter.

Type: String

Length Constraints: Maximum length of 256.

Required: Novalues

A list of the categories for the hyperparameter.

Type: Array of strings

Array Members: Maximum number of 100 items.

Length Constraints: Maximum length of 1000.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

245

Page 250: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DefaultContinuousHyperParameterRangeService: Amazon Personalize

Provides the name and default range of a continuous hyperparameter and whether the hyperparameteris tunable. A tunable hyperparameter can have its value determined during hyperparameter optimization(HPO).

Contents

isTunable

Whether the hyperparameter is tunable.

Type: Boolean

Required: NomaxValue

The maximum allowable value for the hyperparameter.

Type: Double

Valid Range: Minimum value of -1000000.

Required: NominValue

The minimum allowable value for the hyperparameter.

Type: Double

Valid Range: Minimum value of -1000000.

Required: Noname

The name of the hyperparameter.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

246

Page 251: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DefaultHyperParameterRangesService: Amazon Personalize

Specifies the hyperparameters and their default ranges. Hyperparameters can be categorical, continuous,or integer-valued.

Contents

categoricalHyperParameterRanges

The categorical hyperparameters and their default ranges.

Type: Array of DefaultCategoricalHyperParameterRange (p. 245) objects

Array Members: Maximum number of 100 items.

Required: NocontinuousHyperParameterRanges

The continuous hyperparameters and their default ranges.

Type: Array of DefaultContinuousHyperParameterRange (p. 246) objects

Array Members: Maximum number of 100 items.

Required: NointegerHyperParameterRanges

The integer-valued hyperparameters and their default ranges.

Type: Array of DefaultIntegerHyperParameterRange (p. 248) objects

Array Members: Maximum number of 100 items.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

247

Page 252: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

DefaultIntegerHyperParameterRangeService: Amazon Personalize

Provides the name and default range of a integer-valued hyperparameter and whether the hyperparameteris tunable. A tunable hyperparameter can have its value determined during hyperparameter optimization(HPO).

Contents

isTunable

Indicates whether the hyperparameter is tunable.

Type: Boolean

Required: NomaxValue

The maximum allowable value for the hyperparameter.

Type: Integer

Valid Range: Maximum value of 1000000.

Required: NominValue

The minimum allowable value for the hyperparameter.

Type: Integer

Valid Range: Minimum value of -1000000.

Required: Noname

The name of the hyperparameter.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

248

Page 253: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

EventTrackerService: Amazon Personalize

Provides information about an event tracker.

Contents

accountId

The Amazon AWS account that owns the event tracker.

Type: String

Length Constraints: Maximum length of 256.

Required: NocreationDateTime

The date and time (in Unix format) that the event tracker was created.

Type: Timestamp

Required: NodatasetGroupArn

The Amazon Resource Name (ARN) of the dataset group that receives the event data.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NoeventTrackerArn

The ARN of the event tracker.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the event tracker was last updated.

Type: Timestamp

Required: Noname

The name of the event tracker.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

249

Page 254: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Nostatus

The status of the event tracker.

An event tracker can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

Type: String

Length Constraints: Maximum length of 256.

Required: NotrackingId

The ID of the event tracker. Include this ID in requests to the PutEvents API.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

250

Page 255: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

EventTrackerSummaryService: Amazon Personalize

Provides a summary of the properties of an event tracker. For a complete listing, call theDescribeEventTracker (p. 155) API.

Contents

creationDateTime

The date and time (in Unix time) that the event tracker was created.

Type: Timestamp

Required: NoeventTrackerArn

The Amazon Resource Name (ARN) of the event tracker.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the event tracker was last updated.

Type: Timestamp

Required: Noname

The name of the event tracker.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Nostatus

The status of the event tracker.

An event tracker can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

Type: String

Length Constraints: Maximum length of 256.

Required: No

251

Page 256: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

252

Page 257: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

FeatureTransformationService: Amazon Personalize

Provides feature transformation information. Feature transformation is the process of modifying raw inputdata into a form more suitable for model training.

Contents

creationDateTime

The creation date and time (in Unix time) of the feature transformation.

Type: Timestamp

Required: NodefaultParameters

Provides the default parameters for feature transformation.

Type: String to string map

Key Length Constraints: Maximum length of 256.

Value Length Constraints: Maximum length of 1000.

Required: NofeatureTransformationArn

The Amazon Resource Name (ARN) of the FeatureTransformation object.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NolastUpdatedDateTime

The last update date and time (in Unix time) of the feature transformation.

Type: Timestamp

Required: Noname

The name of the feature transformation.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: Nostatus

The status of the feature transformation.

A feature transformation can be in one of the following states:

253

Page 258: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

254

Page 259: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HPOConfigService: Amazon Personalize

Describes the properties for hyperparameter optimization (HPO). For use with the bring-your-own-recipefeature. Do not use for Amazon Personalize native recipes.

Contents

algorithmHyperParameterRanges

The hyperparameters and their allowable ranges.

Type: HyperParameterRanges (p. 258) object

Required: NohpoObjective

The metric to optimize during HPO.

Type: HPOObjective (p. 256) object

Required: NohpoResourceConfig

Describes the resource configuration for HPO.

Type: HPOResourceConfig (p. 257) object

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

255

Page 260: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HPOObjectiveService: Amazon Personalize

The metric to optimize during hyperparameter optimization (HPO).

Contents

metricName

The name of the metric.

Type: String

Length Constraints: Maximum length of 256.

Required: NometricRegex

A regular expression for finding the metric in the training job logs.

Type: String

Length Constraints: Maximum length of 256.

Required: Notype

The type of the metric. Valid values are Maximize and Minimize.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

256

Page 261: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HPOResourceConfigService: Amazon Personalize

Describes the resource configuration for hyperparameter optimization (HPO).

Contents

maxNumberOfTrainingJobs

The maximum number of training jobs when you create a solution version. The maximum value formaxNumberOfTrainingJobs is 40.

Type: String

Length Constraints: Maximum length of 256.

Required: NomaxParallelTrainingJobs

The maximum number of parallel training jobs when you create a solution version. The maximum valuefor maxParallelTrainingJobs is 10.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

257

Page 262: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

HyperParameterRangesService: Amazon Personalize

Specifies the hyperparameters and their ranges. Hyperparameters can be categorical, continuous, orinteger-valued.

Contents

categoricalHyperParameterRanges

The categorical hyperparameters and their ranges.

Type: Array of CategoricalHyperParameterRange (p. 227) objects

Array Members: Maximum number of 100 items.

Required: NocontinuousHyperParameterRanges

The continuous hyperparameters and their ranges.

Type: Array of ContinuousHyperParameterRange (p. 228) objects

Array Members: Maximum number of 100 items.

Required: NointegerHyperParameterRanges

The integer-valued hyperparameters and their ranges.

Type: Array of IntegerHyperParameterRange (p. 259) objects

Array Members: Maximum number of 100 items.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

258

Page 263: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

IntegerHyperParameterRangeService: Amazon Personalize

Provides the name and range of an integer-valued hyperparameter.

Contents

maxValue

The maximum allowable value for the hyperparameter.

Type: Integer

Valid Range: Maximum value of 1000000.

Required: NominValue

The minimum allowable value for the hyperparameter.

Type: Integer

Valid Range: Minimum value of -1000000.

Required: Noname

The name of the hyperparameter.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

259

Page 264: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

RecipeService: Amazon Personalize

Provides information about a recipe. Each recipe provides an algorithm that Amazon Personalize uses inmodel training when you use the CreateSolution (p. 123) operation.

Contents

algorithmArn

The Amazon Resource Name (ARN) of the algorithm that Amazon Personalize uses to train the model.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NocreationDateTime

The date and time (in Unix format) that the recipe was created.

Type: Timestamp

Required: Nodescription

The description of the recipe.

Type: String

Required: NofeatureTransformationArn

The ARN of the FeatureTransformation object.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NolastUpdatedDateTime

The date and time (in Unix format) that the recipe was last updated.

Type: Timestamp

Required: Noname

The name of the recipe.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

260

Page 265: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Required: NorecipeArn

The Amazon Resource Name (ARN) of the recipe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NorecipeType

One of the following values:• PERSONALIZED_RANKING• RELATED_ITEMS• USER_PERSONALIZATION

Type: String

Length Constraints: Maximum length of 256.

Required: Nostatus

The status of the recipe.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

261

Page 266: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

RecipeSummaryService: Amazon Personalize

Provides a summary of the properties of a recipe. For a complete listing, call the DescribeRecipe (p. 159)API.

Contents

creationDateTime

The date and time (in Unix time) that the recipe was created.

Type: Timestamp

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the recipe was last updated.

Type: Timestamp

Required: Noname

The name of the recipe.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NorecipeArn

The Amazon Resource Name (ARN) of the recipe.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the recipe.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++

262

Page 268: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

S3DataConfigService: Amazon Personalize

The configuration details of an Amazon S3 input or output bucket.

Contents

kmsKeyArn

The Amazon Resource Name (ARN) of the Amazon Key Management Service (KMS) key that AmazonPersonalize uses to encrypt or decrypt the input and output files of a batch inference job.

Type: String

Required: Nopath

The file path of the Amazon S3 bucket.

Type: String

Length Constraints: Maximum length of 256.

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

264

Page 269: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

SolutionService: Amazon Personalize

An object that provides information about a solution. A solution is a trained model that can be deployed as acampaign.

Contents

autoMLResult

When performAutoML is true, specifies the best recipe found.

Type: AutoMLResult (p. 213) object

Required: NocreationDateTime

The creation date and time (in Unix time) of the solution.

Type: Timestamp

Required: NodatasetGroupArn

The Amazon Resource Name (ARN) of the dataset group that provides the training data.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NoeventType

The event type (for example, 'click' or 'like') that is used for training the model.

Type: String

Length Constraints: Maximum length of 256.

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the solution was last updated.

Type: Timestamp

Required: NolatestSolutionVersion

Describes the latest version of the solution, including the status and the ARN.

Type: SolutionVersionSummary (p. 275) object

Required: Noname

The name of the solution.

265

Page 270: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NoperformAutoML

When true, Amazon Personalize performs a search for the best USER_PERSONALIZATION recipefrom the list specified in the solution configuration (recipeArn must not be specified). When false (thedefault), Amazon Personalize uses recipeArn for training.

Type: Boolean

Required: NoperformHPO

Whether to perform hyperparameter optimization (HPO) on the chosen recipe. The default is false.

Type: Boolean

Required: NorecipeArn

The ARN of the recipe used to create the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NosolutionArn

The ARN of the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NosolutionConfig

Describes the configuration properties for the solution.

Type: SolutionConfig (p. 268) object

Required: Nostatus

The status of the solution.

A solution can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

266

Page 271: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

267

Page 272: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

SolutionConfigService: Amazon Personalize

Describes the configuration properties for the solution.

Contents

algorithmHyperParameters

Lists the hyperparameter names and ranges.

Type: String to string map

Key Length Constraints: Maximum length of 256.

Value Length Constraints: Maximum length of 1000.

Required: NoautoMLConfig

The AutoMLConfig (p. 212) object containing a list of recipes to search when AutoML is performed.

Type: AutoMLConfig (p. 212) object

Required: NoeventValueThreshold

Only events with a value greater than or equal to this threshold are used for training a model.

Type: String

Length Constraints: Maximum length of 256.

Required: NofeatureTransformationParameters

Lists the feature transformation parameters.

Type: String to string map

Key Length Constraints: Maximum length of 256.

Value Length Constraints: Maximum length of 1000.

Required: NohpoConfig

Describes the properties for hyperparameter optimization (HPO).

Type: HPOConfig (p. 255) object

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++

268

Page 274: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

SolutionSummaryService: Amazon Personalize

Provides a summary of the properties of a solution. For a complete listing, call the DescribeSolution (p. 163)API.

Contents

creationDateTime

The date and time (in Unix time) that the solution was created.

Type: Timestamp

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the solution was last updated.

Type: Timestamp

Required: Noname

The name of the solution.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 63.

Pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*

Required: NosolutionArn

The Amazon Resource Name (ARN) of the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the solution.

A solution can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED• DELETE PENDING > DELETE IN_PROGRESS

Type: String

Length Constraints: Maximum length of 256.

Required: No

270

Page 275: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

271

Page 276: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

SolutionVersionService: Amazon Personalize

An object that provides information about a specific version of a Solution (p. 265).

Contents

creationDateTime

The date and time (in Unix time) that this version of the solution was created.

Type: Timestamp

Required: NodatasetGroupArn

The Amazon Resource Name (ARN) of the dataset group providing the training data.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NoeventType

The event type (for example, 'click' or 'like') that is used for training the model.

Type: String

Length Constraints: Maximum length of 256.

Required: NofailureReason

If training a solution version fails, the reason for the failure.

Type: String

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the solution was last updated.

Type: Timestamp

Required: NoperformAutoML

When true, Amazon Personalize searches for the most optimal recipe according to the solutionconfiguration. When false (the default), Amazon Personalize uses recipeArn.

Type: Boolean

Required: NoperformHPO

Whether to perform hyperparameter optimization (HPO) on the chosen recipe. The default is false.

272

Page 277: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

Type: Boolean

Required: NorecipeArn

The ARN of the recipe used in the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NosolutionArn

The ARN of the solution.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: NosolutionConfig

Describes the configuration properties for the solution.

Type: SolutionConfig (p. 268) object

Required: NosolutionVersionArn

The ARN of the solution version.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the solution version.

A solution version can be in one of the following states:• CREATE PENDING• CREATE IN_PROGRESS• ACTIVE• CREATE FAILED

Type: String

Length Constraints: Maximum length of 256.

Required: No

273

Page 278: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

trainingHours

The time used to train the model. You are billed for the time it takes to train a model. This field is visibleonly after Amazon Personalize successfully trains a model.

Type: Double

Valid Range: Minimum value of 0.

Required: NotrainingMode

The scope of training used to create the solution version. The FULL option trains the solution versionbased on the entirety of the input solution's training data, while the UPDATE option processes only thetraining data that has changed since the creation of the last solution version. Choose UPDATE whenyou want to start recommending items added to the dataset without retraining the model.

Important

The UPDATE option can only be used after you've created a solution version with the FULLoption and the training solution uses the HRNN 冷启动配方 (p. 57).

Type: String

Valid Values: FULL | UPDATE

Required: NotunedHPOParams

If hyperparameter optimization was performed, contains the hyperparameter values of the bestperforming model.

Type: TunedHPOParams (p. 277) object

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

274

Page 279: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize

SolutionVersionSummaryService: Amazon Personalize

Provides a summary of the properties of a solution version. For a complete listing, call theDescribeSolutionVersion (p. 166) API.

Contents

creationDateTime

The date and time (in Unix time) that this version of a solution was created.

Type: Timestamp

Required: NofailureReason

If a solution version fails, the reason behind the failure.

Type: String

Required: NolastUpdatedDateTime

The date and time (in Unix time) that the solution version was last updated.

Type: Timestamp

Required: NosolutionVersionArn

The Amazon Resource Name (ARN) of the solution version.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: Nostatus

The status of the solution version.

A solution version can be in one of the following states:• CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++

275

Page 281: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Events

TunedHPOParamsService: Amazon Personalize

If hyperparameter optimization (HPO) was performed, contains the hyperparameter values of the bestperforming model.

Contents

algorithmHyperParameters

A list of the hyperparameter values of the best performing model.

Type: String to string map

Key Length Constraints: Maximum length of 256.

Value Length Constraints: Maximum length of 1000.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

Amazon Personalize EventsThe following data types are supported by Amazon Personalize Events:

• Event (p. 278)

277

Page 282: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Events

EventService: Amazon Personalize Events

Represents user interaction event information sent using the PutEvents API.

Contents

eventId

An ID associated with the event. If an event ID is not provided, Amazon Personalize generates aunique ID for the event. An event ID is not used as an input to the model. Amazon Personalize usesthe event ID to distinquish unique events. Any subsequent events after the first with the same event IDare not used in model training.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: NoeventType

The type of event. This property corresponds to the EVENT_TYPE field of the Interactions schema.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: Noproperties

A string map of event-specific data that you might choose to record. For example, if a user rates amovie on your site, you might send the movie ID and rating, and the number of movie ratings made bythe user.

Each item in the map consists of a key-value pair. For example,

{"itemId": "movie1"}

{"itemId": "movie2", "eventValue": "4.5"}

{"itemId": "movie3", "eventValue": "3", "numberOfRatings": "12"}

The keys use camel case names that match the fields in the Interactions schema. The itemId andeventValue keys correspond to the ITEM_ID and EVENT_VALUE fields. In the above example, theeventType might be 'MovieRating' with eventValue being the rating. The numberOfRatings wouldmatch the 'NUMBER_OF_RATINGS' field defined in the Interactions schema.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: NosentAt

The timestamp (in Unix time) on the client side when the event occurred.

Type: Timestamp

Required: Yes

278

Page 283: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Amazon Personalize Runtime

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

Amazon Personalize RuntimeThe following data types are supported by Amazon Personalize Runtime:

• PredictedItem (p. 280)

279

Page 284: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Common Errors

PredictedItemService: Amazon Personalize Runtime

An object that identifies an item.

The GetRecommendations (p. 204) and GetPersonalizedRanking (p. 202) APIs return a list ofPredictedItems.

Contents

itemId

The recommended item ID.

Type: String

Length Constraints: Maximum length of 256.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

Common ErrorsThis section lists the errors common to the API actions of all AWS services. For errors specific to an APIaction for this service, see the topic for that API action.

AccessDeniedException

You do not have sufficient access to perform this action.

HTTP Status Code: 400IncompleteSignature

The request signature does not conform to AWS standards.

HTTP Status Code: 400InternalFailure

The request processing has failed because of an unknown error, exception or failure.

HTTP Status Code: 500InvalidAction

The action or operation requested is invalid. Verify that the action is typed correctly.

HTTP Status Code: 400

280

Page 285: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Common Errors

InvalidClientTokenId

The X.509 certificate or AWS access key ID provided does not exist in our records.

HTTP Status Code: 403InvalidParameterCombination

Parameters that must not be used together were used together.

HTTP Status Code: 400InvalidParameterValue

An invalid or out-of-range value was supplied for the input parameter.

HTTP Status Code: 400InvalidQueryParameter

The AWS query string is malformed or does not adhere to AWS standards.

HTTP Status Code: 400MalformedQueryString

The query string contains a syntax error.

HTTP Status Code: 404MissingAction

The request is missing an action or a required parameter.

HTTP Status Code: 400MissingAuthenticationToken

The request must contain either a valid (registered) AWS access key ID or X.509 certificate.

HTTP Status Code: 403MissingParameter

A required parameter for the specified action is not supplied.

HTTP Status Code: 400OptInRequired

The AWS access key ID needs a subscription for the service.

HTTP Status Code: 403RequestExpired

The request reached the service more than 15 minutes after the date stamp on the request or morethan 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp onthe request is more than 15 minutes in the future.

HTTP Status Code: 400ServiceUnavailable

The request has failed due to a temporary failure of the server.

HTTP Status Code: 503

281

Page 286: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Common Parameters

ThrottlingException

The request was denied due to request throttling.

HTTP Status Code: 400ValidationError

The input fails to satisfy the constraints specified by an AWS service.

HTTP Status Code: 400

Common ParametersThe following list contains the parameters that all actions use for signing Signature Version 4 requests witha query string. Any action-specific parameters are listed in the topic for that action. For more informationabout Signature Version 4, see Signature Version 4 Signing Process in the Amazon Web Services GeneralReference.

Action

The action to be performed.

Type: string

Required: YesVersion

The API version that the request is written for, expressed in the format YYYY-MM-DD.

Type: string

Required: YesX-Amz-Algorithm

The hash algorithm that you used to create the request signature.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Valid Values: AWS4-HMAC-SHA256

Required: ConditionalX-Amz-Credential

The credential scope value, which is a string that includes your access key, the date, the region youare targeting, the service you are requesting, and a termination string ("aws4_request"). The value isexpressed in the following format: access_key/YYYYMMDD/region/service/aws4_request.

For more information, see Task 2: Create a String to Sign for Signature Version 4 in the Amazon WebServices General Reference.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

282

Page 287: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南Common Parameters

Required: ConditionalX-Amz-Date

The date that is used to create the signature. The format must be ISO 8601 basic format(YYYYMMDD'T'HHMMSS'Z'). For example, the following date time is a valid X-Amz-Date value:20120325T120000Z.

Condition: X-Amz-Date is optional for all requests; it can be used to override the date used for signingrequests. If the Date header is specified in the ISO 8601 basic format, X-Amz-Date is not required.When X-Amz-Date is used, it always overrides the value of the Date header. For more information, seeHandling Dates in Signature Version 4 in the Amazon Web Services General Reference.

Type: string

Required: ConditionalX-Amz-Security-Token

The temporary security token that was obtained through a call to AWS Security Token Service (AWSSTS). For a list of services that support temporary security credentials from AWS Security TokenService, go to AWS Services That Work with IAM in the IAM User Guide.

Condition: If you're using temporary security credentials from the AWS Security Token Service, youmust include the security token.

Type: string

Required: ConditionalX-Amz-Signature

Specifies the hex-encoded signature that was calculated from the string to sign and the derived signingkey.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Required: ConditionalX-Amz-SignedHeaders

Specifies all the HTTP headers that were included as part of the canonical request. For moreinformation about specifying signed headers, see Task 1: Create a Canonical Request For SignatureVersion 4 in the Amazon Web Services General Reference.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Required: Conditional

283

Page 288: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

Amazon Personalize 的文档历史记录下表描述此 Amazon Personalize 开发人员指南 每次发布时进行的重大修改。如需对此文档更新的通知,您可以订阅 RSS 源。

• 最近一次更新文档的日期:2020 年 4 月 3 日

update-history-change update-history-description update-history-date

新功能 (p. 284) Amazon Personalize 现在公开推荐项目的分数。分数表示 AmazonPersonalize 模型对于用户接下来将选择某个项目的确定性。有关更多信息,请参阅获取建议。

April 3, 2020

新地区 (p. 284) Amazon Personalize 添加了对亚太地区(首尔)区域的支持。有关 Amazon Personalize 支持的AWS 区域的完整列表,请参阅Amazon Web Services 一般参考中的 AWS 区域表或 AWS 区域和终端节点。

January 21, 2020

新功能 (p. 284) Amazon Personalize 现在可根据上下文元数据获取建议。有关更多信息,请参阅获取建议。

December 19, 2019

新区域 (p. 284) Amazon Personalize 增加了对亚太地区(孟买)、亚太地区(悉尼)和加拿大(中部)区域的支持。有关 Amazon Personalize 支持的 AWS 区域的完整列表,请参阅 Amazon Web Services 一般参考 中的 AWS 区域表或 AWS 区域和终端节点。

December 18, 2019

新功能 (p. 284) Amazon Personalize 现在支持批处理建议工作流程。有关更多信息,请参阅 获取批处理建议。

November 14, 2019

Amazon Personalize 通用版 (p. 284)

Amazon Personalize 现可用于一般用途。

June 10, 2019

Amazon Personalize 预览版 (p. 284)

这是 Amazon Personalize 文档的第一个预览版本。

November 28, 2018

284

Page 289: Amazon Personalize - ¼€‘‘Œ‡—

Amazon Personalize 开发人员指南

AWS 词汇表有关最新 AWS 术语,请参阅 AWS General Reference 中的 AWS 词汇表。

285