C.W.K.
Stream
Lesson 02 of 04 · published

Confusion Matrix와 Metric

~28 min · metrics, confusion-matrix

Level 0Scout
0 XP0/48 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

모든 걸 설명하는 네 칸

True positive(TP), false positive(FP), true negative(TN), false negative(FN). 모든 classification metric이 이 네 숫자의 비율. 네 칸을 내재화하면 precision, recall, F1, accuracy를 룩업 없이 화이트보드에서 유도 가능.

외울 가치 있는 정의

  • Precision = TP / (TP + FP) — positive로 예측한 것 중 맞은 비율?
  • Recall = TP / (TP + FN) — 실제 positive 중 잡은 비율?
  • F1 = precision과 recall의 harmonic mean.
  • Accuracy = (TP + TN) / total — class balanced일 때만 유용.

metric 전에 matrix 읽기

단일 숫자 보고 전에 항상 confusion matrix와 per-class report 출력. 네 칸이 종종 "95% accuracy" 모델이 minority class를 한 번도 예측 안 한다는 걸 드러내.

Code

confusion matrix + classification report·python
from sklearn.metrics import confusion_matrix, classification_report

preds = (probs >= 0.5).astype(int)
cm = confusion_matrix(y_val, preds)
print(cm)
print(classification_report(y_val, preds, digits=3))
stakeholder용 예쁜 plot·python
from sklearn.metrics import ConfusionMatrixDisplay
import matplotlib.pyplot as plt

ConfusionMatrixDisplay.from_predictions(y_val, preds, normalize="true")
plt.title("Validation confusion matrix (row-normalized)")
plt.show()

External links

Exercise

classifier에 대해 row-normalized confusion matrix plot. 가장 나쁜 recall class 식별. 그 class의 error 20개 sampling 해서 "hard / ambiguous / data bug"로 label. 데이터 fix / label fix / 한계 수용 중 결정.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.