MCPcopy Create free account
hub / github.com/Speakn0w/RealChart2Code / generate_statistics

Function generate_statistics

RealChart2Code_eval/evaluate_task2.py:988–1119  ·  view source on GitHub ↗
(results_dir: Path, generation_model: str, evaluation_model: str)

Source from the content-addressed store, hash-verified

986
987
988def generate_statistics(results_dir: Path, generation_model: str, evaluation_model: str) -> Dict:
989
990
991 score_files = list(results_dir.glob("**/score_*.json"))
992
993 if not score_files:
994 return {}
995
996 all_scores = []
997 stats_by_difficulty = {}
998 stats_by_category = {}
999
1000
1001 execution_stats = {
1002 'total_tasks': 0,
1003 'code_generated': 0,
1004 'code_executed': 0,
1005 'plot_generated': 0,
1006 'evaluation_completed': 0
1007 }
1008
1009
1010 for score_file in score_files:
1011 with open(score_file, 'r', encoding='utf-8') as f:
1012 score = json.load(f)
1013
1014 difficulty = score['difficulty']
1015 category = score['category']
1016 is_multi = score['is_multi']
1017
1018
1019 execution_stats['total_tasks'] += 1
1020 if score.get('code_generated', False):
1021 execution_stats['code_generated'] += 1
1022 if score.get('execution_success', False):
1023 execution_stats['code_executed'] += 1
1024 if score.get('plot_generated', False):
1025 execution_stats['plot_generated'] += 1
1026 if score.get('plot_generated', False):
1027 execution_stats['evaluation_completed'] += 1
1028
1029
1030 overall_score = score.get('overall_score')
1031 if overall_score:
1032 score_data = {
1033 'visual_structure_total': overall_score['visual_structure_total'],
1034 'visual_structure_max': overall_score['visual_structure_max'],
1035 'execution_quality_total': overall_score['execution_quality_total'],
1036 'execution_quality_max': overall_score['execution_quality_max'],
1037 'data_alignment_total': overall_score['data_alignment_total'],
1038 'data_alignment_max': overall_score['data_alignment_max'],
1039 'overall_total_score': overall_score['overall_total_score'],
1040 'overall_max_score': overall_score['overall_max_score'],
1041 'visual_structure_rate': overall_score['visual_structure_rate'],
1042 'execution_quality_avg': overall_score['execution_quality_avg'],
1043 'data_alignment_rate': overall_score['data_alignment_rate'],
1044 'overall_percentage': overall_score['overall_percentage'],
1045 'difficulty': difficulty,

Callers 1

run_benchmarkFunction · 0.70

Calls 1

calc_statsFunction · 0.70

Tested by

no test coverage detected