Data Balance Lab
Balanced vs imbalanced data, ROS, RUS and SMOTE, the right metrics, leakage when SMOTE comes before the split, and class balance vs group fairness.
العربيةModule experiments (5)
Concepts and formulas
Classification metrics formula
Accuracy, precision, recall, F1 and balanced accuracy.
\mathrm{Acc}=\frac{TP+TN}{n},\;\mathrm{P}=\frac{TP}{TP+FP},\;\mathrm{R}=\frac{TP}{TP+FN},\;F_1=\frac{2PR}{P+R},\;\mathrm{BA}=\frac{\mathrm{TPR}+\mathrm{TNR}}{2}SMOTE synthesis formula
x_nn is one of x_i's k nearest same-class neighbours.
x_{\text{new}}=x_i+\lambda\,(x_{nn}-x_i),\quad \lambda\sim U(0,1)Class imbalance (عدم توازن الفئات)
When one target class is rare, a model can reach high accuracy by predicting the majority class. Use recall, F1, balanced accuracy and the confusion matrix.
SMOTE (SMOTE)
Creates synthetic minority examples by interpolating between an example and one of its k nearest same-class neighbours (Chawla et al., 2002). Apply it to training data only, after the split and inside each CV fold; applying it before the split leaks test information.
Random over/under-sampling (زيادة العينات وتقليلها عشوائياً)
ROS duplicates minority examples; RUS removes majority examples. ROS can overfit; RUS loses information.
Data leakage (تسرب البيانات)
Using test information during training or preprocessing, making results look better than they are, e.g. SMOTE, scaling or feature selection before the split.
Confusion matrix and classification metrics
Four cells: TP, FP, TN, FN; accuracy, precision, recall, F1, specificity and balanced accuracy derive from it. Computing them per group is the basis of fairness measurement.
Questions and guides
Does SMOTE fix bias against groups?
Not necessarily. SMOTE addresses a rare target class; group bias is a different problem needing per-group error measurement and specific mitigation. Apply SMOTE to training data only, after the split.
Module sources
- imbalanced-learn — SMOTEimbalanced-learn developers (2025) — Tool
- SMOTE: Synthetic Minority Over-sampling Technique (arXiv:1106.1813)N. V. Chawla, K. W. Bowyer, L. O. Hall, W. P. Kegelmeyer (2002) — Paper
- Data preprocessing techniques for classification without discrimination. Knowledge and Information Systems 33. DOI 10.1007/s10115-011-0463-8F. Kamiran, T. Calders (2012) — Paper — print reference; no verified open link
