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

Function generate_statistics

RealChart2Code_eval/evaluate_task1.py:910–1034  ·  view source on GitHub ↗
(results_dir: Path, generation_model: str, evaluation_model: str)

Source from the content-addressed store, hash-verified

908
909
910def generate_statistics(results_dir: Path, generation_model: str, evaluation_model: str) -> Dict:
911
912
913 score_files = list(results_dir.glob("**/score_*.json"))
914
915 if not score_files:
916 return {}
917
918 all_scores = []
919 stats_by_difficulty = {}
920 stats_by_category = {}
921
922
923 execution_stats = {
924 'total_tasks': 0,
925 'code_generated': 0,
926 'code_executed': 0,
927 'plot_generated': 0,
928 'evaluation_completed': 0
929 }
930
931
932 for score_file in score_files:
933 with open(score_file, 'r', encoding='utf-8') as f:
934 score = json.load(f)
935
936 difficulty = score['difficulty']
937 category = score['category']
938 is_multi = score['is_multi']
939
940
941 execution_stats['total_tasks'] += 1
942 if score.get('code_generated', False):
943 execution_stats['code_generated'] += 1
944 if score.get('execution_success', False):
945 execution_stats['code_executed'] += 1
946 if score.get('plot_generated', False):
947 execution_stats['plot_generated'] += 1
948 if score.get('plot_generated', False):
949 execution_stats['evaluation_completed'] += 1
950
951
952 overall_score = score.get('overall_score')
953 if overall_score:
954 score_data = {
955 'visual_structure_total': overall_score['visual_structure_total'],
956 'visual_structure_max': overall_score['visual_structure_max'],
957 'execution_quality_total': overall_score['execution_quality_total'],
958 'execution_quality_max': overall_score['execution_quality_max'],
959 'overall_total_score': overall_score['overall_total_score'],
960 'overall_max_score': overall_score['overall_max_score'],
961 'visual_structure_rate': overall_score['visual_structure_rate'],
962 'execution_quality_avg': overall_score['execution_quality_avg'],
963 'overall_percentage': overall_score['overall_percentage'],
964 'difficulty': difficulty,
965 'category': category,
966 'is_multi': is_multi,
967 'execution_success': score.get('execution_success', False),

Callers 1

run_benchmarkFunction · 0.70

Calls 1

calc_statsFunction · 0.70

Tested by

no test coverage detected