36차시. 평가 실습
6. 실습 ④ — 세분화 분석
출처: 원본 PDF 36차시_평가실습.pdf 12쪽 · 쪽 그림 12쪽
전체 점수만으로는 무엇을 고칠지 모릅니다. 쪼개서 봐야 합니다.
📝 eval/analyze.py
from collections import defaultdict
def breakdown(rows, key):
groups = defaultdict(list)
for r in rows:
groups[r[key]].append(r)
print(f"\n■ {key}별 정답률")
# 항목이 많은 순으로 정렬
def sort_key(pair):
return -len(pair[1])
for name, items in sorted(groups.items(), key=sort_key):
hit = sum(i["correct"] for i in items)
rate = hit / len(items) * 100
bar = "█" * int(rate / 5)
print(f" {str(name):<12} {hit:>2}/{len(items):<2} "
f"{rate:>5.1f}% {bar}")
def failures(rows):
print("\n■ 실패 사례")
for r in rows:
if r["correct"]:
continue
print(f" {r['id']} [{r['type']}/{r['difficulty']}] "
f"grade={r['grade']} 재검색{r['researches']}회")
print(f" 사유: {r['reason'][:60]}")
print(f" 답변: {r['answer'][:60]}...")
breakdown(rows, "difficulty")
breakdown(rows, "type")
failures(rows)
실행 결과 예시
─────────────────────────────────────────────
─────────
■ 전체 평가 (n=35)
Correctness : 88.6%
Faithfulness : 0.963
Abstention : 100.0% (부재 질문 8건)
평균 응답 : 3.4초
P95 응답 : 8.2초
■ difficulty별 정답률
easy 14/14 100.0% ████████████████████
medium 12/14 85.7% █████████████████
hard 5/ 7 71.4% ██████████████
■ type별 정답률
fact 11/11 100.0% ████████████████████
variant 6/ 7 85.7% █████████████████
absent 8/ 8 100.0% ████████████████████
compound 4/ 6 66.7% █████████████
conditional 2/ 3 66.7% █████████████
■ 실패 사례
Q014 [compound/hard] grade=pass 재검색0회
사유: 교환 조건만 답하고 환불 조건이 누락됨
답변: 상품 불량의 경우 30일 이내에 교환이 가능합니다[1]...
Q031 [compound/hard] grade=pass 재검색0회
사유: 배송비 부담 주체가 한쪽만 언급됨
...