What is focal loss and why does it help with class imbalance?
hardAnswer
- Focal loss = -, a modification of cross-entropy that adds a modulating factor .
- When is high (easy example), the loss is heavily down-weighted; when is low (hard example), the modulator is close to 1 — focus on hard examples. recovers cross-entropy; is the standard for RetinaNet.
- Combined with alpha per class, it addresses both easy-example overwhelm and class imbalance in the same objective — dominant loss in dense object detection.
Check yourself — multiple choice
- Focal loss is a scaled MSE
- Cross-entropy multiplied by ^γ — down-weights easy examples, focuses on hard ones
- Same as class weights
- Only works for regression
Focal ^γ · CE — hard-example focus for imbalanced dense prediction.
#imbalance
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- When should you use PR-AUC instead of ROC-AUC?
- How do you handle class imbalance in a dataset?
- Why is the base rate of the positive class critical to know?
- How do class weights work in logistic regression, and when do you use them?
- You trained Naive Bayes on balanced data but deploy on data where positives are 1%. What happens and what do you do?
- How do you handle class imbalance in XGBoost / LightGBM?