reranking
1.0.0
Rerankingは、ランク付けされたアイテムを指定されたアイテム属性分布に再ランクするアルゴリズムを提供します。
このパッケージは、推奨システムまたは検索エンジンの後処理モジュラーとして使用できます。
LinkedIn Talent Searchへのアプリケーションを備えた検索および推奨システムでのペーパーフェアネスを意識したランキングに触発されました。
「リクルーターに候補者を勧める」ことを例として(これは、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 after 、それぞれ0.412と0.172であり、ランク付けされたアイテム属性分布の正規化された割引累積KL-divergence(NDKL)と目的の分布です。 (低い方が良いです。)
より多くの例をご覧ください。