Only 1% of loan applications are defaults. Which approach handles the imbalance correctly?
- Exam domain
- Data Manipulation and Preparation23% of the exam
- Difficulty
- Medium
- In this mock
- 11 questions on this domainPractise this domain
Why the exam asks this
Data Manipulation and Preparation (23% of the exam)
Objective in the exam guide: Handling class imbalance and generating synthetic data
Class imbalance appears often in practice.
Why D is the answer
Oversample or weight the minority class in the training split only
Resampling or class weights belong in training only. Resampling before the split leaks synthetic copies into the test set and inflates scores.
Remember: Split first, then resample training data.
How it works
Class imbalance is handled with resampling, synthetic samples such as SMOTE, or class weights, on training data only.
In detail
- Resample training data only.
- Use precision, recall or PR AUC.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Oversample before splitting so the test set is balanced tooWrongMost tempting
Oversampling before splitting leaks data.
Why it tempts: A balanced test set sounds fairer.
B. Ignore it and report accuracyWrong
Accuracy hides minority failure.
C. Delete most of the test setWrong
Shrinking the test set weakens evaluation.
D. Oversample or weight the minority class in the training split onlyRight
Split first, then resample training data.
Use case
An illustrative scenario, not a real incident.
Illustrative: SMOTE on training data lifts default recall from 20% to 65%.
See it in different ways
flowchart LR S0["Split first"] --> S1["Resample or weight training set"] --> S2["Train"] --> S3["Evaluate on untouched test set"]
How to read this chart
- Read it in order: Split first, then Resample or weight training set, then Train, then Evaluate on untouched test set.
mindmap
root(("Imbalance"))
n1["Resampling"]
n2["Oversample"]
n3["Undersample"]
n4["SMOTE"]
n5["Weights"]
n6["Class weights"]
n7["Metrics"]
n8["Recall"]
n9["PR AUC"]How to read this chart
- The centre is "Imbalance".
- "Resampling" covers "Oversample", "Undersample", "SMOTE".
- "Weights" covers "Class weights".
- "Metrics" covers "Recall", "PR AUC".
Related questions
Learn more
- Our lesson: Data manipulation and preparation with cuDF
- Practise Data Manipulation and Preparation questions in the mock exam
- Source: Over-sampling (imbalanced-learn)
- Source: Common pitfalls and recommended practices (scikit-learn)
- cuDF documentation (RAPIDS)
- pandas documentation
- Apache Parquet documentation
- Over-sampling (imbalanced-learn)