File size: 2,426 Bytes
cf17729 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
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)
|