MLA-C01 Data Preparation for Machine Learning Practice Question
A data scientist is training a binary classifier on a highly imbalanced dataset (1:100 class ratio). The dataset contains 500,000 rows and 30 features. The data is stored in S3 in Parquet format. The data scientist wants to use SageMaker's built-in XGBoost algorithm. Which data preparation technique should the data scientist apply to best address the class imbalance without causing data leakage?
⚠ Common exam trap
AWS often tests the misconception that resampling techniques (like SMOTE or random oversampling) are always safe, when in fact applying them before splitting introduces data leakage, whereas built-in parameters like scale_pos_weight avoid this pitfall.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use the scale_pos_weight parameter in XGBoost to assign higher weight to the minority class.
The scale_pos_weight parameter in XGBoost directly adjusts the loss function to penalize misclassifications of the minority class more heavily, effectively handling class imbalance without modifying the dataset. This avoids data leakage because the weighting is applied during training only, not during preprocessing, and does not involve any synthetic data generation or resampling that could inadvertently expose test information.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Undersample the majority class to create a balanced dataset, then split.
Why it's wrong here
Undersampling discards 99% of majority-class rows, destroying the signal needed to model the 1:100 ratio and leaving too few examples for 30 features. It is tempting because balanced classes suit accuracy metrics, and undersampling is valid when the majority class is genuinely redundant or tiny datasets make resampling costly.
- ✓
Use the scale_pos_weight parameter in XGBoost to assign higher weight to the minority class.
Why this is correct
scale_pos_weight multiplies the minority class's gradient contribution during XGBoost training, countering the 1:100 skew. Because it adjusts only the loss weighting rather than duplicating or synthesising rows, no information crosses between train and validation splits, avoiding the leakage that resampling before splitting would cause.
- ✗
Oversample the minority class using SMOTE on the entire dataset before splitting into train/validation sets.
Why it's wrong here
SMOTE synthesises minority points before splitting, so interpolated neighbours straddle train and validation folds, leaking information and inflating validation scores. It is tempting because SMOTE directly rebalances classes, and it is correct when applied only to the training fold after the split.
- ✗
Randomly oversample the minority class by duplicating rows, then perform stratified train/test split.
Why it's wrong here
Duplicating minority rows before splitting lets identical copies land in both train and test sets, leaking information and inflating test metrics. Oversampling is valid, but must occur after the split, or via SMOTE on training folds only. Class weighting in XGBoost avoids duplication entirely.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
One of 665 original MLA-C01 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This MLA-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the MLA-C01 exam.