MLCrack

    CLASSICAL ML ยท INTERVIEW QUESTION

    How do you handle class imbalance? Compare different approaches.

    ๐Ÿ”ด advanced ยท Supervised Learning

    Hint: Think about data-level, algorithm-level, and evaluation approaches.

    Answer

    Data-level:

    1. Oversampling minority (SMOTE creates synthetic examples along feature space)

    2. Undersampling majority (random, Tomek links, NearMiss)

    3. Augmentation for minorities. Algorithm-level:

    4. Class weights: inverse frequency weighting in loss function.

    5. Cost-sensitive learning: different misclassification costs.

    6. Focal loss: down-weights easy examples, focuses on hard ones (used in object detection).

    7. Consider anomaly detection when useful positive labels are scarce and anomaly assumptions fit. Ensemble:

    8. Balanced Random Forest

    9. EasyEnsemble (ensemble of undersampled datasets).

    Evaluation: use AUPRC, F1, balanced accuracy โ€” NOT accuracy. Threshold: tune classification threshold based on the PR curve. Best practices: try class weights first (simplest), then SMOTE if needed. No imbalance ratio by itself requires anomaly detection. With useful labels, compare supervised cost-sensitive or ranking models, evaluate at natural deployment prevalence, and set thresholds using costs and review capacity.