reranking
1.0.0
RERANKING提供算法将排名的项目重新列为任何指定的项目属性分布。
该软件包可以用作推荐系统或搜索引擎的后处理模块。
受纸张公平感知的搜索和推荐系统排名的启发,并应用于LinkedIn人才搜索。
以“向招聘人员的推荐候选人”为榜样(本文中强调的LinkedIn招聘人员服务是这种情况),搜索引擎排名是根据候选人对招聘人员的公平表现的受保护属性和人口统计奇偶(例如性别和人口统计)的分布进行了重新排列的。
例如,当我们向用户推荐产品时,可以使用推荐系统来将每个用户的产品偏好分布(可以通过购买日志或视图日志获得)来对项目排名进行对等级排名,以获得更个性化的建议。
$ pip install reranking import reranking
item_attribute = [ "a1" , "a1" , "a1" , "a2" , "a1" , "a1" , "a1" , "a2" , "a2" , "a1" ]
desired_distribution = { "a1" : 0.5 , "a2" : 0.5 }
rerank_indices = reranking . rerank (
item_attribute , # attributes of the ranked items
desired_distribution , # desired item distribution
max_na = None , # controls the max number of attribute categories applied
k_max = None , # length of output, if None, k_max is the length of `item_attribute`
algorithm = "det_greedy" , # "det_greedy", "det_cons", "det_relaxed", "det_const_sort"
verbose = False , # if True, the output is with detailed information
)
print ( rerank_indices ) rerank_indices是[0, 3, 1, 7, 2, 8, 4, 5, 6, 9]这是重新排列所需分布后的项目索引列表。如果有足够的所需项目,则重新排列列表的最高项目将具有与所需分布相同的分布。 ( item_attribute与项目列表具有相同的顺序,因此它包含等级/分数信息。)
# Evaluate the before&after of the re-ranking result above
item_attribute_reranked = [ item_attribute [ i ] for i in rerank_indices ]
before = reranking . ndkl ( item_attribute , desired_distribution )
after = reranking . ndkl ( item_attribute_reranked , desired_distribution )
print ( f" { before :.3f } , { after :.3f } " ) before分别为0.412和after 0.172分别是排名项目属性分布和所需分布的归一化累积KL-Divergence(NDKL)。 (较低。)
可以在此处找到更多示例。