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)。 (較低。)
可以在此處找到更多示例。