| import pandas as pd |
| import numpy as np |
|
|
| TASKS = ['domain', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species', 'immunogenicity', 'link'] |
|
|
| for dataset in ['strict', 'strict_3']: |
| print(f"\n{'='*80}") |
| print(f"DATASET: {dataset.upper()}") |
| print(f"{'='*80}") |
| |
| df = pd.read_csv(f'benchmark_comparison_{dataset}.csv', index_col=0) |
| |
| |
| ranks = df.rank(ascending=False, method='min') |
| |
| |
| mean_ranks = ranks.mean(axis=1).sort_values() |
| |
| |
| print("\n๐ ACCURACY BY TASK (sorted by mean rank):") |
| print("-"*100) |
| |
| |
| df['Mean_Rank'] = mean_ranks |
| df_sorted = df.sort_values('Mean_Rank') |
| |
| |
| for col in df_sorted.columns: |
| if col != 'Mean_Rank': |
| df_sorted[col] = df_sorted[col].apply(lambda x: f"{x*100:.1f}%" if pd.notnull(x) else "-") |
| else: |
| df_sorted[col] = df_sorted[col].apply(lambda x: f"{x:.2f}") |
| |
| print(df_sorted.to_string()) |
| |
| print("\n\n๐ RANKINGS BY TASK:") |
| print("-"*100) |
| for task in TASKS: |
| if task in df.columns: |
| task_ranks = df[task].sort_values(ascending=False) |
| print(f"\n{task.upper():15} | ", end="") |
| for i, (model, acc) in enumerate(task_ranks.items(), 1): |
| if isinstance(acc, str): |
| acc_val = float(acc.replace('%', ''))/100 |
| else: |
| acc_val = acc |
| print(f"#{i}: {model}({acc_val*100:.1f}%) ", end="") |
| |
| print("\n\n\n๐ MEAN RANK SUMMARY:") |
| print("-"*50) |
| for model, rank in mean_ranks.items(): |
| print(f" {model:20} : {rank:.2f}") |
| |
| |
| winner = mean_ranks.idxmin() |
| print(f"\n๐ฅ BEST MODEL (lowest mean rank): {winner} ({mean_ranks[winner]:.2f})") |
|
|
|
|