MLA-C01 Data Preparation for Machine Learning Practice Question
A data engineer is using AWS Glue to prepare a dataset for ML. The engineer wants to split the dataset into training and testing sets while preserving the distribution of the target variable. Which TWO methods achieve this goal? (Select TWO)
⚠ Common exam trap
A common mix-up: candidates confuse random splitting (which is available in many tools like Glue and Athena) with stratified splitting, assuming that any 'random' operation preserves distribution, but only stratified methods explicitly maintain class proportions.
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 `train_test_split` function from scikit-learn in a SageMaker notebook
The `train_test_split` function from scikit-learn supports the `stratify` parameter, which preserves the distribution of the target variable when splitting a dataset into training and testing sets. This is a standard, reliable method for stratified splitting in Python-based ML workflows, and it can be used directly in a SageMaker notebook.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use Amazon Athena to create views with random sampling
Why it's wrong here
Athena random sampling does not guarantee stratified splits.
- ✓
Use the `train_test_split` function from scikit-learn in a SageMaker notebook
Why this is correct
The stratify parameter maintains class proportions.
- ✗
Use AWS Glue's built-in random split transform
Why it's wrong here
Random split does not preserve target distribution.
- ✓
Use a custom Spark script with stratified sampling
Why this is correct
Stratified sampling ensures proportional representation of target classes.
- ✗
Use Amazon SageMaker's built-in SplitType parameter in a Processing Job
Why it's wrong here
SplitType only supports random division.
Go deeper
Related to this question
About these practice questions
One of 835 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.