Buckets:
tahamajs/Sysmem2_in_AI / ComputerAssignments /CA14_multi_agent_reasoning /scripts /visualize_results.py
| #!/usr/bin/env python3 | |
| import json | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import pandas as pd | |
| from pathlib import Path | |
| def create_performance_comparison(results_file: str, output_dir: str): | |
| with open(results_file, 'r') as f: | |
| results = json.load(f) | |
| agents = [] | |
| success_rates = [] | |
| execution_times = [] | |
| confidence_scores = [] | |
| for demo in results["demos"]: | |
| agents.append(demo["agent"]) | |
| success_rates.append(1.0 if demo["success"] else 0.0) | |
| execution_times.append(demo["execution_time"]) | |
| confidence_scores.append(demo.get("confidence", demo.get("reasoning_quality", 0.0))) | |
| fig, axes = plt.subplots(2, 2, figsize=(15, 10)) | |
| fig.suptitle('Language Agent Architecture Performance Comparison', fontsize=16) | |
| axes[0, 0].bar(agents, success_rates, color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4']) | |
| axes[0, 0].set_title('Success Rate') | |
| axes[0, 0].set_ylabel('Success Rate') | |
| axes[0, 0].set_ylim(0, 1) | |
| axes[0, 1].bar(agents, execution_times, color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4']) | |
| axes[0, 1].set_title('Execution Time (seconds)') | |
| axes[0, 1].set_ylabel('Time (s)') | |
| axes[1, 0].bar(agents, confidence_scores, color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4']) | |
| axes[1, 0].set_title('Reasoning Quality / Confidence') | |
| axes[1, 0].set_ylabel('Score') | |
| axes[1, 0].set_ylim(0, 1) | |
| x = range(len(agents)) | |
| width = 0.25 | |
| axes[1, 1].bar([i - width for i in x], success_rates, width, label='Success Rate', alpha=0.8) | |
| axes[1, 1].bar(x, confidence_scores, width, label='Quality/Confidence', alpha=0.8) | |
| axes[1, 1].set_title('Combined Performance Metrics') | |
| axes[1, 1].set_ylabel('Score') | |
| axes[1, 1].set_xticks(x) | |
| axes[1, 1].set_xticklabels(agents, rotation=45) | |
| axes[1, 1].legend() | |
| plt.tight_layout() | |
| output_path = Path(output_dir) / 'agent_performance_comparison.png' | |
| plt.savefig(output_path, dpi=300, bbox_inches='tight') | |
| plt.close() | |
| print(f"๐ Performance comparison saved to: {output_path}") | |
| df = pd.DataFrame({ | |
| 'Agent': agents, | |
| 'Success Rate': success_rates, | |
| 'Execution Time (s)': execution_times, | |
| 'Quality/Confidence': confidence_scores | |
| }) | |
| csv_path = Path(output_dir) / 'agent_performance_summary.csv' | |
| df.to_csv(csv_path, index=False) | |
| print(f"๐ Performance summary saved to: {csv_path}") | |
| return df | |
| if __name__ == "__main__": | |
| results_file = "results/demo_all_agents_results.json" | |
| output_dir = "visualizations" | |
| Path(output_dir).mkdir(exist_ok=True) | |
| df = create_performance_comparison(results_file, output_dir) | |
| print("\n๐ Performance Summary:") | |
| print(df.to_string(index=False)) | |
Xet Storage Details
- Size:
- 2.83 kB
- Xet hash:
- 5fbab8d00aa0b6d8b0679939e2abaa91e3ee1011effafd55915b51a606c3ced6
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.