[AI] F-score

JAsmine_log·2025년 9월 2일
0


(자료: Wikipedia)

F-Score

  • Precision (정밀도): 모델이 "맞다"라고 예측한 것 중에 실제로 맞은 비율
    (based on (realy) relevant things)

    Precision=TPTP+FP\text{Precision} = \frac{TP}{TP + FP}
  • Recall (재현율): 실제로 맞는 것 중에 모델이 맞다고 예측한 비율
    (over the retireved things from the test or experience)

    Recall=TPTP+FN\text{Recall} = \frac{TP}{TP + FN}

여기서

  • TP = True Positive (정답을 맞춘 경우)
  • FP = False Positive (틀렸는데 맞다고 한 경우)
  • FN = False Negative (맞는데 틀렸다고 한 경우)

F1-Score$

Balanced F-measure

F1 정의

  • F1은 Precision과 Recall을 동일하게 중요하게 취급한다.
  • F1은 Precision과 Recall의 조화평균 (harmonic mean)으로 정의한다:
F1=2PrecisionRecallPrecision+RecallF_1 = 2 \cdot \frac{\text{Precision} \cdot \text{Recall}}{\text{Precision} + \text{Recall}}
  • 산술평균(Arithmetic mean)은 단순 평균인데,
  • 조화평균(Harmonic mean)은 두 값이 모두 크지 않으면 값이 작아 진다.
    즉, F1은 Precision과 Recall이 둘 다 높아야 높은 값을 가질 수 있고, 한쪽이라도 낮으면 크게 깎인다.

이를 TP, FP, FN으로 바꿔 쓰면:

F1=2TP2TP+FP+FNF_1 = \frac{2TP}{2TP + FP + FN}

Fβ-ScoreF_{\beta}\text{-Score}

Generalized F-measure

  • 하지만 경우에 따라 "재현율(Recall)이 더 중요"하거나 "정밀도(Precision)이 더 중요"할 수 있다.

    • 예: 질병 진단 → 놓치면 안 되니까 Recall ↑ 중요
    • 스팸 필터 → 잘못 차단하면 안 되니까 Precision ↑ 중요
  • 이를 위해 β (베타) 파라미터를 사용한다.

Fβ-ScoreF_{\beta}\text{-Score}

Fβ=(1+β2)PrecisionRecall(β2Precision)+RecallF_\beta = \frac{(1+\beta^2) \cdot \text{Precision} \cdot \text{Recall}}{(\beta^2 \cdot \text{Precision}) + \text{Recall}}
  • β > 1 이면 Recall 쪽 가중치 ↑ (Recall을 더 중요시)
  • β < 1 이면 Precision 쪽 가중치 ↑ (Precision을 더 중요시)
  • β = 1 이면 F1이 됩니다.
  • F1: Precision과 Recall을 균형 있게 평가.
  • Fβ-ScoreF_{\beta}\text{-Score}: Precision과 Recall 중 어느 쪽을 더 강조할지 β\beta로 조절.

예시

간단 예시

  • β\beta = 2 → Recall을 Precision보다 2배 중요하게 본다. 정밀도 가중
  • β\beta = 0.5 → Precision을 Recall보다 2배 중요하게 본다. 재현율 가중

Precision이 더 높은 경우

가정:

  • TP=80, FP=20, FN=40
  • Precision =8080+20=0.8000= \frac{80}{80+20} = 0.8000
  • Recall =8080+40=0.6667= \frac{80}{80+40} = 0.6667

계산

F1=2PRP+R=20.80.66670.8+0.66670.7273F1= \frac{2PR}{P+R} = \frac{2\cdot0.8\cdot0.6667}{0.8+0.6667} \approx \mathbf{0.7273}
F0.5=(1+0.52)PR0.52P+R0.7692F_{0.5}= \frac{(1+0.5^2)PR}{0.5^2 P + R} \approx \mathbf{0.7692}
F2=(1+22)PR22P+R0.6897F_{2}= \frac{(1+2^2)PR}{2^2 P + R} \approx \mathbf{0.6897}

해석:

  • Precision이 높은 상황이라 F0.5F_{0.5}가장 높고, Recall을 중시하는 F2F_2는 상대적으로 낮아짐.

Recall이 더 높은 경우

가정:

  • TP=50, FP=50, FN=10
  • Precision =5050+50=0.5000= \frac{50}{50+50} = 0.5000
  • Recall =5050+10=0.8333= \frac{50}{50+10} = 0.8333

계산:

  • F1 0.6250\approx \mathbf{0.6250}
  • F0.5F_{0.5} (정밀도 가중) 0.5435\approx \mathbf{0.5435}
  • F2F_{2} (재현율 가중) 0.7353\approx \mathbf{0.7353}

해석:

  • Recall이 높은 상황이라 **F2F_2**가 가장 유리하게 나옴. 반대로 정밀도 쪽을 강조하는 F0.5F_{0.5}는 낮아짐.

핵심 포인트 요약

  • F1: Precision과 Recall을 동일 가중으로 결합 → 둘 중 하나라도 낮으면 크게 깎임.
  • FβF_\beta: β>1\beta>1이면 Recall을, β<1\beta<1이면 Precision을 더 중요하게 반영.

https://en.wikipedia.org/wiki/F-score

profile
Everyday Research & Development

0개의 댓글