How do you handle class imbalance in a classification problem?
Class imbalance is when one class vastly outnumbers others, causing models to favor the majority and appear accurate while missing the minority. Approaches fall into several groups. Data-level: oversample the minority (e.g. SMOTE, which synthesizes new examples) or undersample the majority. Algorithm-level: apply class weights so minority errors cost more, which most libraries support directly. Evaluation-level: stop using accuracy and instead track precision, recall, F1, and PR-AUC, and choose the decision threshold deliberately rather than defaulting to 0.5. You can also gather more minority data or reframe as anomaly detection when imbalance is extreme. The right choice depends on the business cost of false negatives versus false positives; always resample only the training folds, never the validation or test set.