import json from collections import Counter # ============================== # LOAD LOGS # ============================== with open("results/error_logs.json") as f: logs = json.load(f) total_errors = len(logs) # ============================== # ERROR DISTRIBUTION # ============================== error_counts = Counter([e["error_type"] for e in logs]) print("\n" + "="*50) print("๐Ÿ“Š TEXT-to-SQL ERROR DASHBOARD") print("="*50) print(f"\n๐Ÿ”ข Total Errors Logged: {total_errors}") print("\n๐Ÿ“Š ERROR DISTRIBUTION:") print("-"*30) for k, v in error_counts.items(): percent = (v / total_errors) * 100 print(f"{k:<20} : {v:>4} ({percent:.1f}%)") # ============================== # TOP ERROR # ============================== top_error = error_counts.most_common(1)[0] print("\n๐Ÿ”ฅ MOST COMMON ERROR:") print("-"*30) print(f"{top_error[0]} ({top_error[1]} times)") # ============================== # SQL OPERATION ANALYSIS # ============================== join_count = 0 where_count = 0 group_count = 0 order_count = 0 for e in logs: sql = e["sql"].lower() if "join" in sql: join_count += 1 if "where" in sql: where_count += 1 if "group by" in sql: group_count += 1 if "order by" in sql: order_count += 1 print("\n๐Ÿง  SQL OPERATION ANALYSIS:") print("-"*30) print(f"JOIN used in : {join_count} queries") print(f"WHERE used in : {where_count} queries") print(f"GROUP BY used in : {group_count} queries") print(f"ORDER BY used in : {order_count} queries") # ============================== # SAMPLE ERRORS # ============================== print("\n๐Ÿงช SAMPLE ERROR CASES:") print("-"*50) for i, e in enumerate(logs[:3], 1): print(f"\nCase {i}:") print(f"Q : {e['question']}") print(f"SQL : {e['sql']}") print(f"Type: {e['error_type']}") # ============================== # FINAL INSIGHT # ============================== print("\n๐Ÿ“Œ FINAL INSIGHT:") print("-"*30) if top_error[0] == "wrong_column": print("โš ๏ธ Model struggles with column selection (schema understanding issue).") elif top_error[0] == "wrong_table": print("โš ๏ธ Model struggles with correct table mapping.") elif top_error[0] == "syntax_error": print("โš ๏ธ Model generates invalid SQL syntax.") else: print("โš ๏ธ Mixed errors โ€” needs general improvement.") print("\n" + "="*50) print("โœ… DASHBOARD COMPLETE") print("="*50)