Skip to content

Commit

Permalink
Update scoring.py
Browse files Browse the repository at this point in the history
Added function compute_sugeno_rank to compute ranking based only on Sugeno scores
  • Loading branch information
pg427 committed Sep 19, 2024
1 parent 8edb0a2 commit 87f211b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tr_sys/tr_ars/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 87f211b

Please sign in to comment.