Spaces:
Paused
Paused
| #!/usr/bin/env python3 | |
| """Display ranking results in readable format""" | |
| import json | |
| with open('test_results_option_b.json') as f: | |
| data = json.load(f) | |
| print('=' * 80) | |
| print('WHAT WAS RANKED - FULL BREAKDOWN') | |
| print('=' * 80) | |
| print() | |
| print(f"Total Trials Found: {data['results']['total_found']}") | |
| print(f"Trials Ranked by 355M: {data['benchmarking']['trials_ranked_by_355m']}") | |
| print(f"355M Ranking Time: {data['benchmarking']['355m_ranking_time']:.1f}s ({data['benchmarking']['355m_ranking_time']/60:.1f} minutes)") | |
| print() | |
| print('TOP 5 TRIALS (After 355M Perplexity Ranking):') | |
| print('-' * 80) | |
| print() | |
| for trial in data['trials'][:5]: | |
| rank_after = trial['scoring']['rank_after_355m'] | |
| rank_before = trial['scoring']['rank_before_355m'] | |
| print(f"Rank #{rank_after}: {trial['nct_id']}") | |
| print(f" Title: {trial.get('title', 'No title')}") | |
| print() | |
| print(f" π SCORES:") | |
| print(f" Hybrid Score (RAG): {trial['scoring']['hybrid_score']:.4f} ({trial['scoring']['hybrid_score']*100:.1f}%)") | |
| if trial['scoring']['perplexity']: | |
| print(f" Perplexity (355M): {trial['scoring']['perplexity']:.2f} (lower = better)") | |
| print(f" Perplexity Score: {trial['scoring']['perplexity_score']:.4f} ({trial['scoring']['perplexity_score']*100:.1f}%)") | |
| print(f" Combined Score: {trial['scoring']['relevance_score']:.4f} ({trial['scoring']['relevance_score']*100:.1f}%)") | |
| print() | |
| if rank_before != rank_after: | |
| if rank_before > rank_after: | |
| print(f" π Rank Change: {rank_before} β {rank_after} β¬οΈ IMPROVED by {rank_before - rank_after} position(s)!") | |
| else: | |
| print(f" π Rank Change: {rank_before} β {rank_after} β¬οΈ Dropped by {rank_after - rank_before} position(s)") | |
| else: | |
| print(f" β‘οΈ Rank Change: {rank_before} β {rank_after} (No change)") | |
| print() | |
| print(f" π URL: https://clinicaltrials.gov/study/{trial['nct_id']}") | |
| print() | |
| print('-' * 80) | |
| print() | |
| print() | |
| print('π RANKING IMPACT SUMMARY:') | |
| print('-' * 80) | |
| print(f" Average rank change: {data['benchmarking']['average_rank_change']:.1f} positions") | |
| print(f" Max rank improvement: {data['benchmarking']['max_rank_improvement']} position(s)") | |
| print() | |
| print(f" Top 3 Perplexity Scores:") | |
| for i, perp in enumerate(data['benchmarking']['top_3_perplexity_scores'], 1): | |
| print(f" {i}. {perp:.2f} (lower = more relevant)") | |
| print() | |