langchain_experimental.recommenders.amazon_personalize.AmazonPersonalize

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

Amazon Personalize实时操作运行时包装器。

更多信息请参阅[此链接](https://docs.aws.amazon.com/personalize/latest/dg/API_Operations_Amazon_Personalize_Runtime.html).

参数
  • campaign_arn (可选[str]) – str,可选:用于获取推荐项活动的Amazon资源名称(ARN)。

  • recommender_arn (可选[str]) – str,可选:用于获取推荐项的推荐器 Amazon资源名称(ARN)

  • client (可选[Any]) – 可选:boto3客户端

  • credentials_profile_name (可选[str]) – str,可选:AWS配置文件名

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

示例


personalize_client = AmazonPersonalize (

campaignArn=’<my-campaign-arn>’ )

方法

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

get_personalized_ranking(user_id, input_list)

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

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

从Amazon Personalize服务中获取推荐。

__init__(campaign_arn: Optional[str] = None, recommender_arn: Optional[str] = None, client: Optional[Any] = None, credentials_profile_name: Optional[str] = None, region_name: Optional[str] = None)[源代码]
参数
  • campaign_arn (可选[str]) –

  • recommender_arn (可选[str]) –

  • client (可选[Any]) –

  • credentials_profile_name (可选[str]) –

  • region_name (可选[str]) –

get_personalized_ranking(user_id: str, input_list: List[str], filter_arn: Optional[str], filter_values: Optional[Mapping[str, str]], context: Optional[Mapping[str, str]], metadata_columns: Optional[Mapping[str, Sequence[str]]], **kwargs: Any) Mapping[str, Any][来源]

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

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

参数
  • user_id (str) – 字符串,必需:检索推荐的用户标识符

  • input_list (List[str]) – List[str],必需:按itemId排列的项目列表

  • filter_arn (Optional[str]) – string,可选:应用此过滤器的ARN

  • filter_values (Optional[Mapping[str, str]]) – Mapping,可选:过滤推荐时使用的值。

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

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

  • kwargs (Any) –

返回值

Mapping[str, Any]: 返回个性化排名

和推荐Id。

返回类型

response

示例


personalize_client = AmazonPersonalize(campaignArn='<my-campaign-arn>')

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

input_list=["123,"256"])

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

从Amazon Personalize服务中获取推荐。

请参阅更多详情: https://docs.aws.amazon.com/personalize/latest/dg/API_RS_GetRecommendations.html

参数
  • user_id (可选[str]) – str, 可选:要检索推荐的用户标识符

  • item_id (可选[str]) – str, 可选:要检索推荐的项标识符

  • filter_arn (可选[str]) – str, 可选:应用于返回推荐的筛选器ARN

  • filter_values (Optional[Mapping[str, str]]) – Mapping,可选:过滤推荐时使用的值。

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

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

  • promotions (可选[Sequence[Mapping[str, Any]]]) – Sequence, 可选:应用于推荐请求的推广。

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

  • kwargs (Any) –

返回值

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

返回类型

response

示例


personalize_client = AmazonPersonalize(campaignArn='<my-campaign-arn>')

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