F1 Score
더 많은 작업
The F1 Score is a classification metric that combines precision and recall into a single measure, providing a balanced assessment of a model’s accuracy in identifying positive instances. It is particularly useful when both false positives and false negatives are important to minimize.
The F1 Score is the harmonic mean of precision and recall, calculated as:
This metric ranges from 0 to 1, with a score closer to 1 indicating better model performance. The F1 Score emphasizes the balance between precision and recall, making it suitable when both metrics are critical.
The F1 Score is valuable in scenarios where:
- Both false positives and false negatives are costly
- The dataset is imbalanced, and accuracy alone would not provide a clear measure of performance
- The goal is to achieve a trade-off between precision and recall
The F1 Score is most appropriate when:
- There is a need to balance precision and recall, such as in medical diagnosis or fraud detection
- Neither false positives nor false negatives can be ignored
While the F1 Score is a balanced metric, it has limitations:
- It does not distinguish between precision and recall, which may be undesirable when one is more important than the other
- It can be less informative in cases where class distribution is extremely imbalanced
When the F1 Score alone is not sufficient, consider other metrics to complement the evaluation:
- Precision: Focuses on the accuracy of positive predictions, suitable when false positives are costly.
- Recall: Focuses on the completeness of positive predictions, important when false negatives are costly.
- AUC-ROC: Provides a more comprehensive view across different thresholds for positive classification.
F-beta Score(Fβ)는 F1 Score 를 일반화한 지표로, 정밀도(Precision)와 재현율(Recall) 중 어느 쪽에 더 비중을 둘지를 β 로 정한다.
- Fβ = (1 + β²) × Precision × Recall / (β² × Precision + Recall)
β 는 "재현율을 정밀도보다 몇 배 중요하게 볼 것인가" 를 뜻한다. β = 1 이면 두 값을 같은 비중으로 보는 조화 평균, 즉 F1 Score 가 된다.
| β 값 | 비중 | 쓰는 곳 |
|---|---|---|
| β = 1 (F1) | 정밀도와 재현율을 같은 비중으로 본다 | 두 오류의 비용이 비슷할 때 |
| β > 1 (예: F2) | 재현율에 더 비중을 둔다 | 양성을 놓치면 안 되는 문제(질병 진단, 사기 탐지) |
| β < 1 (예: F0.5) | 정밀도에 더 비중을 둔다. β = 0.5 이면 정밀도에 재현율의 2배 가중치를 주어 평균한 셈이다 | 잘못된 양성 판정의 비용이 큰 문제(스팸 필터) |
- β 가 1 보다 크면 재현율, 1 보다 작으면 정밀도 쪽이다. "β 가 1 보다 크면 정밀도에, 작으면 재현율에 비중을 둔다" 는 방향을 거꾸로 적은 틀린 설명이다.
- β 가 0 에 가까워지면 Fβ 는 정밀도에, β 가 커질수록 재현율에 가까워진다.
- 정밀도와 재현율이 같으면(P = R) 식이 (1 + β²)P² / ((1 + β²)P) = P 가 되어 β 와 관계없이 같은 값이 나온다. β 에 따라 결과가 달라지는 것은 두 값이 다를 때뿐이다.