Statistics Glossary → Class imbalance and balanced weights
Class imbalance and balanced weightsconcept
The situation in a classification problem where one class has far fewer observations than the others, and the inversely proportional weights given to classes to stop this from pushing the model toward the majority class.
In data where 2% of cases are positive, a model that calls everything 'negative' reaches 98% accuracy yet is useless. Many learning algorithms minimise total error and so tend to ignore the minority class. Balanced weighting gives each class the weight n / (K·n_k), where K is the number of classes and n_k the number of observations in that class. This equalises the total weight of each class and makes errors on the minority class more costly. Alternatives are oversampling the minority, undersampling the majority, or simply moving the classification threshold.
Weighting shifts the model's probability estimates: the probabilities from a weighted model no longer reflect the true prevalence and must be recalibrated if calibrated probabilities are needed. With imbalanced data, performance should be judged not by accuracy but by measures such as sensitivity, specificity, balanced accuracy, F1, Cohen's κ or the precision-recall curve. In cross-validation, folds should be stratified to preserve the class proportions.
An everyday example
Only 20 of 1000 loan applications ended in default. With balanced weights, each default gets a weight of 1000 / (2 × 20) = 25 and each repaid loan 1000 / (2 × 980) ≈ 0.51. The model now sees the 20 defaults as having the same total importance as the 980 repaid loans and learns to catch risky applications.
In MerQur
In the random forest, support vector machine and gradient boosting, the 'Imbalanced classes: balanced weights' option applies n/(K·n_k) class weights; in the decision tree the same option uses equal prior probabilities (prior = 1/K). In the ROC curve, 'Additional output: PR curve and average precision (AP)' gives an additional summary that is useful with imbalanced classes.
Analyses where this concept appears
ROC CurveRandom ForestSupport Vector Machine (SVM)Gradient BoostingDecision Tree (CART)
Related concepts
Classification threshold (cut-off)F1 score, MCC and balanced accuracy