Q14Machine Learning
Question
Discuss various methods to deal with highly imbalanced datasets.
Answer
A critical engineering review of handling Imbalanced Datasets. Violently analyzes the failure of accuracy metrics, and details the mathematical execution of SMOTE (Oversampling) and strict Algorithmic Penalization (Class Weights).
An Imbalanced Dataset is a catastrophic machine learning crisis. If a dataset contains 99,000 legitimate credit card transactions and only 1,000 fraudulent ones, a "dumb" model that violently predicts Legitimate 100% of the time will achieve 99% Mathematical Accuracy, but will fail spectacularly in the real world. Standard algorithms are mathematically biased toward the majority class.
1. Metric Alteration (Abandoning Accuracy)
The engineer must instantly abandon "Accuracy." The architecture must be evaluated using the F1-Score, Precision-Recall AUC, or the Confusion Matrix. These metrics violently expose the model's catastrophic failure to detect the minority class (Fraud).
2. Data-Level Resampling Architectures
- Random Undersampling: Violently delete 98,000 legitimate transactions at random until both classes have exactly 1,000 samples. Demerit: Massive loss of critical mathematical data.
- Random Oversampling: Blindly duplicate the 1,000 fraud samples 99 times. Demerit: Causes horrific model Overfitting.
- SMOTE (Synthetic Minority Over-sampling Technique): The absolute optimal mathematical solution. SMOTE does not duplicate data; it uses K-Nearest Neighbors to analyze the fraud points and mathematically generates brand new, synthetic, highly realistic fraud data points to balance the dataset.
3. Algorithm-Level Modifications
- Class Weights (Cost-Sensitive Learning): The algorithm's Cost Function is mathematically violently altered. A false prediction on a legitimate transaction incurs a penalty of
1. However, a false prediction on a Fraud transaction incurs a massive penalty of100. The Gradient Descent algorithm is mathematically terrified of missing a fraud case, forcing it to focus on the minority class.