Download data/processed/RQ2/aggregate_llm_share.py from AINativeOps/AINativeBench: direct link, hf CLI and curl.
- Browser
- Download file 5.89 kB
-
https://huggingface.co/datasets/AINativeOps/AINativeBench/resolve/main/data/processed/RQ2/aggregate_llm_share.py
- Command line
-
hf download hf://datasets/AINativeOps/AINativeBench/data/processed/RQ2/aggregate_llm_share.py
-
curl -L -o aggregate_llm_share.py https://huggingface.co/datasets/AINativeOps/AINativeBench/resolve/main/data/processed/RQ2/aggregate_llm_share.py
5.89 kB
| #!/usr/bin/env python3 | |
| import pandas as pd | |
| import numpy as np | |
| from pathlib import Path | |
| def aggregate_llm_share(): | |
| base_dir = Path(__file__).parent | |
| series_order = [ | |
| ( | |
| "Email Responder", | |
| ["EmailResponder", "EmailResponder-MCP"], | |
| ), | |
| ( | |
| "Recruitment", | |
| [ | |
| "RecruitmentAssistant-A2A", | |
| "RecruitmentAssistant-H_A2A", | |
| "RecruitmentAssistant-MCP", | |
| ], | |
| ), | |
| ("Markdown Val.", ["MarkdownValidator", "MarkdownValidator-MCP"]), | |
| ("Game Builder", ["GameBuilder", "GameBuilder-MCP"]), | |
| ( | |
| "SQL Asst.", | |
| ["SQLAssistant-A2A", "SQLAssistant-H_A2A", "SQLAssistant-MCP"], | |
| ), | |
| ( | |
| "Landing Pg.", | |
| [ | |
| "LandingPageGenerator-A2A", | |
| "LandingPageGenerator-H_A2A", | |
| "LandingPageGenerator-MCP", | |
| ], | |
| ), | |
| ( | |
| "Book Writer", | |
| [ | |
| "BookWriter-A2A", | |
| "BookWriter-H_A2A", | |
| "BookWriter-MCP", | |
| ], | |
| ), | |
| ( | |
| "Social M. M.", | |
| [ | |
| "SocialMediaManager-A2A", | |
| "SocialMediaManager-H_A2A", | |
| "SocialMediaManager-MCP", | |
| ], | |
| ), | |
| ] | |
| projects = [] | |
| csv_files = [] | |
| project_to_display_name = {} | |
| for series_name, project_list in series_order: | |
| for project_name in project_list: | |
| project_dir = base_dir / project_name | |
| if project_dir.is_dir(): | |
| csv_file = project_dir / "performance_breakdown_summary_by_model.csv" | |
| if csv_file.exists(): | |
| if "-A2A_mix" in project_name: | |
| display_name = f"{series_name} (A2A_mix)" | |
| elif "-A2A" in project_name: | |
| display_name = f"{series_name} (A2A)" | |
| elif "-MCP" in project_name: | |
| display_name = f"{series_name} (MCP)" | |
| else: | |
| # Projects without a suffix are Pure CrewAI baselines | |
| display_name = f"{series_name} (CrewAI)" | |
| projects.append(project_name) | |
| project_to_display_name[project_name] = display_name | |
| csv_files.append(csv_file) | |
| else: | |
| print(f"Warning: {project_name} missing CSV file") | |
| print(f"Found {len(projects)} projects with CSV files") | |
| models = [ | |
| "GPT-5", | |
| "GPT-4o-mini", | |
| "DeepSeek-V3-1", | |
| "DeepSeek-R1", | |
| "Gemini-2.5-flash", | |
| "Gemini-2.5-flash-nothinking", | |
| "Qwen3-235b", | |
| ] | |
| data_dict = {model: [] for model in models} | |
| weight_dict = {model: [] for model in models} | |
| total_weighted_sum = 0.0 | |
| total_weight = 0.0 | |
| for project, csv_file in zip(projects, csv_files): | |
| try: | |
| df = pd.read_csv(csv_file) | |
| for model in models: | |
| model_data = df[df["model"] == model] | |
| if not model_data.empty: | |
| llm_share = model_data["LLM_share"].values[0] | |
| llm_share = min(llm_share, 1.0) | |
| llm_share = round(llm_share, 4) | |
| data_dict[model].append(llm_share) | |
| comp_time = model_data["total_components_time"].values[0] | |
| weight = float(comp_time) if pd.notna(comp_time) else 0.0 | |
| weight_dict[model].append(weight) | |
| if pd.notna(llm_share) and weight > 0: | |
| total_weighted_sum += llm_share * weight | |
| total_weight += weight | |
| else: | |
| data_dict[model].append(None) | |
| weight_dict[model].append(0.0) | |
| except Exception as e: | |
| print(f"Error reading {csv_file}: {e}") | |
| for model in models: | |
| data_dict[model].append(None) | |
| weight_dict[model].append(0.0) | |
| result_df = pd.DataFrame(data_dict, index=projects) | |
| result_df.index = result_df.index.map(project_to_display_name) | |
| result_df.index.name = "Model" | |
| result_df = result_df.T | |
| # Time-weighted overall average across all models and projects | |
| overall_avg = ( | |
| round(total_weighted_sum / total_weight, 4) if total_weight > 0 else np.nan | |
| ) | |
| overall_row_name = "Overall Average (time-weighted, all models & projects)" | |
| overall_row = pd.Series( | |
| {col: overall_avg for col in result_df.columns}, name=overall_row_name | |
| ) | |
| result_df = pd.concat([result_df, overall_row.to_frame().T]) | |
| output_file = base_dir / "llm_share_summary.csv" | |
| result_df.to_csv(output_file, float_format="%.4f") | |
| print(f"\nCSV saved to: {output_file}") | |
| print(f"\nShape: {result_df.shape[0]} models × {result_df.shape[1]} projects") | |
| return result_df | |
| def generate_latex_table(df): | |
| num_cols = len(df.columns) | |
| latex = [] | |
| latex.append("\\begin{table*}[htbp]") | |
| latex.append("\\centering") | |
| latex.append("\\small") | |
| latex.append(f"\\begin{{tabular}}{{l{'c' * num_cols}}}") | |
| latex.append("\\toprule") | |
| header = "Model & " + " & ".join(df.columns) + " \\\\" | |
| latex.append(header) | |
| latex.append("\\midrule") | |
| for idx, row in df.iterrows(): | |
| row_str = ( | |
| str(idx) | |
| + " & " | |
| + " & ".join([f"{v:.4f}" if pd.notna(v) else "-" for v in row]) | |
| + " \\\\" | |
| ) | |
| latex.append(row_str) | |
| latex.append("\\bottomrule") | |
| latex.append("\\end{tabular}") | |
| latex.append("\\caption{LLM Share by Model and Project}") | |
| latex.append("\\label{tab:llm_share}") | |
| latex.append("\\end{table*}") | |
| return "\n".join(latex) | |
| if __name__ == "__main__": | |
| aggregate_llm_share() | |