From 87f211b811e46fc61d873a115d6111e2c4f908a5 Mon Sep 17 00:00:00 2001 From: pg427 <58840680+pg427@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:21:32 -0400 Subject: [PATCH] Update scoring.py Added function compute_sugeno_rank to compute ranking based only on Sugeno scores --- tr_sys/tr_ars/scoring.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tr_sys/tr_ars/scoring.py b/tr_sys/tr_ars/scoring.py index eca0877d..584dbe55 100644 --- a/tr_sys/tr_ars/scoring.py +++ b/tr_sys/tr_ars/scoring.py @@ -28,7 +28,7 @@ def compute_from_results(results): result['sugeno']=sugeno_score result['weighted_mean']=weighted_mean - final_ranks = compute_sugeno_weighted_mean_rank(sugeno_scores,weighted_means)[2] + final_ranks = compute_sugeno_rank(sugeno_scores,weighted_means) for i, rank in enumerate(final_ranks): #casting to int because some come through as pandas int64 results[i]["rank"]=int(rank) @@ -125,3 +125,11 @@ def compute_sugeno_weighted_mean_rank(sugeno_scores, weighted_mean_scores): sugeno_weighted_mean_rank[j] = i + weight_order_copy[idj] return sugeno_rank, weighted_mean_rank, sugeno_weighted_mean_rank +''' +THIS FUNCTION PRODUCES THE RANKING ORDER BASED ON SUGENO SCORES ONLY +''' +def compute_sugeno_rank(sugeno_scores): + sugeno_sorted = sorted(enumerate(sugeno_scores), key=lambda x: x[1], reverse=True) + ranks = {index: rank + 1 for rank, (index, value) in enumerate(sugeno_sorted)} + indexed_ranks = [ranks[index] for index in range(len(sugeno_scores))] + return indexed_ranks \ No newline at end of file