亚马逊个性化推荐#

class langchain_experimental.recommenders.amazon_personalize.AmazonPersonalize(campaign_arn: str | None = None, recommender_arn: str | None = None, client: Any | None = None, credentials_profile_name: str | None = None, region_name: str | None = None)[source]#

用于执行实时操作的Amazon Personalize Runtime包装器。

查看[此链接以获取更多详情](https://docs.aws.amazon.com/personalize/latest/dg/API_Operations_Amazon_Personalize_Runtime.html).

Parameters:
  • campaign_arn (str | None) – str, 可选: 用于获取推荐的活动的亚马逊资源名称(ARN)。

  • recommender_arn (str | None) – str, 可选: 用于获取推荐的推荐器的亚马逊资源名称 (ARN)

  • client (Any | None) – 可选: boto3 客户端

  • credentials_profile_name (str | None) – str, 可选 :AWS 配置文件名称

  • region_name (str | None) – str, 可选: AWS 区域, 例如 us-west-2

示例


personalize_client = AmazonPersonalize (

campaignArn=’’ )

方法

__init__([campaign_arn, recommender_arn, ...])

get_personalized_ranking(user_id, input_list)

为给定用户重新排序推荐物品列表。

get_recommendations([user_id, item_id, ...])

从Amazon Personalize服务获取推荐。

__init__(campaign_arn: str | None = None, recommender_arn: str | None = None, client: Any | None = None, credentials_profile_name: str | None = None, region_name: str | None = None)[source]#
Parameters:
  • campaign_arn (str | None)

  • recommender_arn (str | None)

  • client (任意 | )

  • credentials_profile_name (str | None)

  • region_name (str | None)

get_personalized_ranking(user_id: str, input_list: List[str], filter_arn: str | None = None, filter_values: Mapping[str, str] | None = None, context: Mapping[str, str] | None = None, metadata_columns: Mapping[str, Sequence[str]] | None = None, **kwargs: Any) Mapping[str, Any][source]#

为给定用户重新排列推荐项目列表。

https://docs.aws.amazon.com/personalize/latest/dg/API_RS_GetPersonalizedRanking.html

Parameters:
  • user_id (str) – str, 必填: 用于检索推荐信息的用户标识符

  • input_list (List[str]) – List[str], 必填: 一个需要排序的项目列表(通过itemId)

  • filter_arn (str | None) – str, 可选: 要应用的过滤器的ARN

  • filter_values (Mapping[str, str] | None) – 映射,可选:用于过滤推荐的值。

  • context (Mapping[str, str] | None) – 映射,可选:获取推荐时使用的上下文元数据

  • metadata_columns (Mapping[str, Sequence[str]] | None) – 映射, 可选: 作为响应的一部分返回的元数据列。

  • kwargs (Any)

Returns:

Mapping[str, Any]: 返回 personalizedRanking

和 recommendationId。

Return type:

响应

示例


personalize_client = AmazonPersonalize(campaignArn=’’ )

response = personalize_client.get_personalized_ranking(user_id=”1”,

输入列表=[“123,”256”])

get_recommendations(user_id: str | None = None, item_id: str | None = None, filter_arn: str | None = None, filter_values: Mapping[str, str] | None = None, num_results: int | None = 10, context: Mapping[str, str] | None = None, promotions: Sequence[Mapping[str, Any]] | None = None, metadata_columns: Mapping[str, Sequence[str]] | None = None, **kwargs: Any) Mapping[str, Any][source]#

从Amazon Personalize服务获取推荐。

查看更多详情: https://docs.aws.amazon.com/personalize/latest/dg/API_RS_GetRecommendations.html

Parameters:
  • user_id (str | None) – str, 可选: 用于检索推荐信息的用户标识符

  • item_id (str | None) – str, 可选: 用于检索推荐的商品标识符

  • filter_arn (str | None) – str, 可选: 应用于返回推荐的过滤器的ARN

  • filter_values (Mapping[str, str] | None) – 映射,可选:用于过滤推荐的值。

  • num_results (int | None) – int, 可选: 默认=10: 返回的结果数量

  • context (Mapping[str, str] | None) – 映射,可选:获取推荐时使用的上下文元数据

  • promotions (Sequence[Mapping[str, Any]] | None) – 序列,可选:应用于推荐请求的促销活动。

  • metadata_columns (Mapping[str, Sequence[str]] | None) – 映射, 可选: 作为响应的一部分返回的元数据列。

  • kwargs (Any)

Returns:

Mapping[str, Any]: 返回一个itemList和recommendationId。

Return type:

响应

示例


personalize_client = AmazonPersonalize(campaignArn=’’ )

response = personalize_client.get_recommendations(user_id=”1”)