1.3.5

Question Answer & Explanation
### Question 1 - Resolving Numeric Data Imbalance with Data Retention

A financial services company is building a fraud detection model using a highly imbalanced tabular dataset stored in Amazon S3. The dataset consists of 98% legitimate transactions and 2% fraudulent transactions. Compliance policies mandate that all legitimate records must be retained in the training set to ensure the model learns the full variance of normal behavior, but the team needs to significantly improve the model's ability to detect fraud.

Which TWO techniques can effectively resolve this class imbalance without dropping any legitimate records? (Select TWO)

- A) Random undersampling of the legitimate transactions.
- B) Synthetic Minority Over-sampling Technique (SMOTE) to generate synthetic fraudulent transactions.
- C) Applying higher class weights to the fraudulent transactions during model training.
- D) Duplicating the existing fraudulent transactions until the classes are balanced.
- E) Removing the non-numeric features to simplify the model's decision boundary.
Correct Answers: B and C

Correct Options Analysis:
- B is Correct: SMOTE generates new, synthetic instances for the minority class by interpolating between existing minority examples. This increases the minority class representation without dropping majority records.
- C is Correct: Assigning a higher class weight (or cost) to the minority class penalizes the model more heavily for misclassifying the rare class, forcing the algorithm to pay more attention to the fraudulent transactions without modifying the underlying dataset.

Distractor Analysis:
- A is Incorrect: Random undersampling drops majority class records, which violates the compliance constraint to retain all legitimate records.
- D is Incorrect: While duplicating (oversampling) the minority class does not drop majority records, it often leads to overfitting because the model sees the exact same minority examples repeatedly. SMOTE is the preferred oversampling method for numeric data.
- E is Incorrect: Removing non-numeric features is a feature selection/dimensionality reduction step and does not inherently resolve class imbalance.

> Key Takeaway: For tabular numeric data, if you cannot drop majority class records, use SMOTE to generate synthetic minority samples or adjust class weights in the algorithm (e.g., scale_pos_weight in XGBoost) to penalize minority class errors more heavily.
### Question 2 - Image Dataset Imbalance and Overfitting Prevention

A manufacturing company is training a computer vision model on Amazon SageMaker to detect a rare surface defect on circuit boards. The image dataset contains 10,000 images of non-defective boards and only 50 images of defective boards. The team needs to balance the dataset and increase the variety of the minority class while minimizing the risk of overfitting and introducing the least operational overhead.

Which approach is the MOST appropriate to resolve this class imbalance?

- A) Copy the 50 defective images 200 times to match the majority class count.
- B) Apply random undersampling to reduce the non-defective images to 50.
- C) Apply image augmentation techniques (e.g., random rotation, flipping, and brightness adjustment) to the defective images.
- D) Train the model using the imbalanced dataset and rely on high overall accuracy as the success metric.
Correct Answer: C

Correct Options Analysis:
- C is Correct: For image datasets, data augmentation (like rotation, cropping, and color adjustment) is the standard technique to generate additional variation for the rare class. It creates diverse synthetic images from the existing 50 defective examples, balancing the class without simply duplicating data, thereby reducing overfitting risk.

Distractor Analysis:
- A is Incorrect: Duplicating the minority images 200 times leads to severe overfitting, as the model will memorize those exact 50 images rather than generalizing to new defects.
- B is Incorrect: Randomly discarding 9,950 non-defective images destroys valuable information and drastically reduces the dataset size, hurting the model's ability to learn normal variations.
- D is Incorrect: Training on heavily imbalanced data without mitigation will result in a model that predicts "non-defective" almost every time. Overall accuracy will be misleadingly high (the accuracy paradox), but the model will fail to detect actual defects.

> Key Takeaway: In image classification, use data augmentation (transformations) to synthetically expand the minority class and prevent overfitting, rather than simple duplication or majority undersampling.
### Question 3 - Text Dataset Imbalance and Augmentation

A customer support team is training a text classification model to route incoming tickets. The dataset is heavily imbalanced: 80% "General Inquiry", 19% "Technical Support", and 1% "Legal Escalation". The team must improve the model's performance on the "Legal Escalation" class without changing the distribution of the majority classes. They want to use NLP-specific techniques to generate additional training examples for the rare class.

Which technique is the MOST appropriate for this text dataset?

- A) Applying Synthetic Minority Over-sampling Technique (SMOTE) directly to the raw text strings.
- B) Using back-translation to generate paraphrased examples of the "Legal Escalation" tickets.
- C) Randomly deleting "General Inquiry" tickets until all classes are equal.
- D) Applying class weights only to the "Technical Support" class.
Correct Answer: B

Correct Options Analysis:
- B is Correct: Back-translation (translating text to another language and back to the original) is an effective NLP data augmentation technique that generates syntactically varied but semantically identical text. It is ideal for creating synthetic minority class examples for text datasets.

Distractor Analysis:
- A is Incorrect: SMOTE relies on interpolating between feature vectors in continuous numeric space. It cannot be applied directly to raw text strings or un-embedded categorical data without complex, custom embeddings.
- C is Incorrect: Undersampling the majority class destroys potentially useful data and is unnecessary when augmentation can be used instead.
- D is Incorrect: The problem specifically identifies "Legal Escalation" as the rare class needing help, not "Technical Support". Furthermore, the prompt asks for data augmentation to generate examples, not algorithmic weighting.

> Key Takeaway: For text datasets, use NLP-specific augmentation techniques like back-translation, synonym replacement, or random word insertion to generate minority class samples, as numeric techniques like SMOTE do not apply to raw text.
### Question 4 - Algorithmic Class Weighting in SageMaker XGBoost

A healthcare startup is using the Amazon SageMaker XGBoost built-in algorithm to predict a rare medical condition. The dataset is 99.5% negative (healthy) and 0.5% positive (disease). The data science team is prohibited from modifying the raw dataset in Amazon S3 due to strict data governance policies, but they must ensure the model does not ignore the minority class.

Which configuration approach satisfies these constraints with the LEAST operational overhead?

- A) Use AWS Glue DataBrew to oversample the positive class and save a new balanced dataset to S3.
- B) Configure the scale_pos_weight hyperparameter in the SageMaker XGBoost estimator to a value greater than 1.
- C) Implement a custom PyTorch training script to apply focal loss during gradient descent.
- D) Set the eval_metric to error and train on the raw data.
Correct Answer: B

Correct Options Analysis:
- B is Correct: The scale_pos_weight hyperparameter in XGBoost controls the weight of the positive class relative to the negative class. Setting it to a high value (e.g., the ratio of negative to positive instances) forces the algorithm to penalize misclassifications of the minority class more heavily, resolving the imbalance algorithmically without touching the underlying data.

Distractor Analysis:
- A is Incorrect: Using AWS Glue DataBrew to oversample modifies the dataset, violating the data governance constraint that prohibits changing the raw data.
- C is Incorrect: Writing a custom PyTorch script to implement focal loss introduces unnecessary operational overhead and complexity when the built-in XGBoost algorithm already supports class weighting natively.
- D is Incorrect: Training on raw data with the standard error metric will cause the model to be biased towards the majority class. The error metric does not resolve class imbalance.

> Key Takeaway: When data modification is prohibited, resolve class imbalance algorithmically by utilizing built-in algorithm hyperparameters like scale_pos_weight in XGBoost, which penalizes minority class errors during training.
### Question 5 - Addressing the Accuracy Paradox

A machine learning engineer is evaluating a binary classification model trained on an imbalanced dataset where 95% of the data belongs to the negative class. The engineer reports that the model achieves an overall accuracy of 95%. However, business stakeholders complain that the model fails to identify almost any of the positive class instances (the actual business priority).

Why is the reported accuracy misleading, and what metric should be used instead to evaluate the positive class?

- A) Accuracy is misleading because the model can achieve 95% accuracy by simply predicting the negative class every time; the engineer should use Precision, Recall, or F1-score.
- B) Accuracy is misleading because it cannot be calculated when the dataset is imbalanced; the engineer should use Mean Squared Error.
- C) Accuracy is misleading because the minority class carries more weight; the engineer should use Root Mean Square Logarithmic Error (RMSLE).
- D) Accuracy is misleading because it factors in False Positives; the engineer should use Specificity.
Correct Answer: A

Correct Options Analysis:
- A is Correct: This is the accuracy paradox. In a 95% negative dataset, a naive model predicting "negative" for every sample will score 95% accuracy. To properly evaluate the detection of the positive class, metrics that focus on the minority class—such as Precision (how many predicted positives are actually positive), Recall (how many actual positives were caught), and the F1-score (harmonic mean of both)—must be used.

Distractor Analysis:
- B is Incorrect: Accuracy can easily be calculated on imbalanced datasets; it is simply mathematically uninformative for the minority class. Mean Squared Error is a regression metric, not suitable for classification.
- C is Incorrect: RMSLE is a regression metric used for predicting continuous values, not for evaluating classification boundaries or class imbalance.
- D is Incorrect: Specificity measures the true negative rate, which evaluates how well the model identifies the negative class, which is the exact opposite of the business priority (identifying the positive class).

> Key Takeaway: Overall accuracy is highly misleading for imbalanced datasets because it masks the failure to detect the minority class. Always evaluate imbalanced models using Precision, Recall, F1-score, or the Area Under the Precision-Recall Curve (PR-AUC).
### Question 6 - Stratified Splitting for Imbalanced Data

A data science team is preparing an imbalanced dataset for training and validation. The dataset contains 100,000 rows, with 1,000 rows belonging to the rare positive class. The team must split the data into a training set and a validation set to ensure that the model's performance is evaluated correctly and that both sets maintain the original 100:1 class ratio.

Which data splitting technique is the MOST appropriate to meet this requirement?

- A) Random split without replacement.
- B) Chronological split based on the event timestamp.
- C) Stratified split based on the target label.
- D) K-Fold cross-validation with random assignment.
Correct Answer: C

Correct Options Analysis:
- C is Correct: Stratified splitting ensures that the proportion of classes in the training and validation sets exactly matches the proportion in the full dataset. This guarantees that the rare positive class is represented in both the training data (so the model can learn) and the validation data (so the metric reflects real-world performance).

Distractor Analysis:
- A is Incorrect: A random split might approximately preserve the ratio, but with very rare classes (1%), it risks randomly placing too few or even zero positive instances into the validation set due to variance.
- B is Incorrect: A chronological split is used for time-series data to prevent look-ahead bias. It does not guarantee class balance and might exacerbate imbalance if the positive class appears seasonally or in specific time clusters.
- D is Incorrect: Standard K-Fold without stratification suffers from the same risk as random splitting: some folds might end up with no positive class instances, making validation metrics impossible to calculate or highly volatile.

> Key Takeaway: Always use stratified sampling when splitting imbalanced datasets to guarantee that the minority class is proportionally represented in both training and validation/test sets, preventing empty validation classes.
### Question 7 - Distinguishing Class Imbalance from Representation Bias

A retail company is building a model to predict customer churn. The dataset contains an equal number of male and female customers (perfectly balanced across gender). However, 95% of the records are labeled "No Churn" and 5% are labeled "Churn". The ML engineer states that the dataset suffers from "representation bias" and plans to fix it by oversampling the female class.

What is the flaw in the engineer's assessment?

- A) The dataset actually suffers from class imbalance, not representation bias; the engineer should oversample the "Churn" class instead.
- B) The dataset suffers from both class imbalance and representation bias; the engineer should undersample the female class.
- C) The dataset suffers from label bias; the engineer should use SMOTE on the male class.
- D) The engineer's assessment is correct; gender is the primary source of the 95/5 split.
Correct Answer: A

Correct Options Analysis:
- A is Correct: The problem described is an imbalance in the outcome label (95% No Churn, 5% Churn), which is textbook class imbalance. Representation bias refers to a dataset misrepresenting the population (e.g., missing a demographic entirely), but the gender split here is 50/50. Therefore, the engineer should focus on the target label imbalance, not the gender representation.

Distractor Analysis:
- B is Incorrect: The prompt states there is an equal number of male and female customers, so there is no representation bias regarding gender to fix.
- C is Incorrect: Label bias occurs when the ground truth labels are systematically incorrect (e.g., human annotators label subjectively). There is no evidence of this in the prompt. SMOTE on the male class is also irrelevant to the churn label imbalance.
- D is Incorrect: The engineer's assessment is flawed. Class imbalance and representation bias are distinct problems. The 95/5 split is about the target variable, not the gender feature.

> Key Takeaway: Class imbalance refers to an unequal distribution of the target label (e.g., 95% churn vs 5% no-churn). Representation bias refers to an unequal distribution of features or demographics compared to the real world. The remedies are not interchangeable.
### Question 8 - Evaluating Undersampling Risks in Large-Scale Data

A click-through rate (CTR) prediction model operates on a massive dataset of 1 billion impressions, where only 0.1% resulted in a click. To reduce training costs and balance the dataset, a junior data scientist proposes randomly dropping 99.9% of the negative (no-click) records to achieve a 50/50 split. The senior engineer rejects this proposal.

What is the PRIMARY risk associated with the junior data scientist's proposed undersampling approach?

- A) It will cause the model to overfit the minority class because the dataset size is too small.
- B) It discards valuable information and variance from the majority class, potentially hurting the model's ability to learn the true decision boundary of non-clicks.
- C) It will artificially inflate the model's overall accuracy on the validation set.
- D) It violates AWS service quotas by processing too few rows in Amazon SageMaker.
Correct Answer: B

Correct Options Analysis:
- B is Correct: While undersampling reduces dataset size and balances classes, randomly dropping 99.9% of the negative class destroys a massive amount of information. In CTR prediction, the nuances of why users do not click are just as important as why they do. Truncating the majority class so aggressively shrinks the feature space of the majority class, leading to a poor decision boundary and high false-positive rates in production.

Distractor Analysis:
- A is Incorrect: Dropping majority data does not cause overfitting on the minority class; rather, it causes underfitting or poor generalization on the majority class because the model hasn't seen the full variance of non-clicks.
- C is Incorrect: Undersampling to a 50/50 split actually reduces the accuracy paradox by making the baseline accuracy 50%, but it doesn't artificially inflate it.
- D is Incorrect: AWS SageMaker does not have service quotas that restrict training based on "too few rows."

> Key Takeaway: Aggressive undersampling on massive datasets discards valuable majority-class information. It is often better to use class weighting, downsampling to a moderate ratio (e.g., 10:1 instead of 1:1), or ensemble methods rather than forcing a perfect 50/50 balance via random deletion.
### Question 9 - Multimodal Dataset Imbalance Resolution

A media company is training a multimodal model to classify inappropriate video content. The dataset contains numeric metadata (duration, view count), text (video title and description), and image frames extracted from the video. The target class "Inappropriate" is severely underrepresented. The team needs a comprehensive strategy to balance the dataset across all modalities without simply duplicating the minority records.

Which combination of techniques is the MOST appropriate to apply?

- A) Apply SMOTE to the numeric metadata, back-translation to the text, and image augmentation to the frames.
- B) Apply SMOTE to the text, back-translation to the image frames, and image augmentation to the numeric metadata.
- C) Apply random undersampling to the numeric metadata, and drop the text features entirely.
- D) Duplicate the entire multimodal record (metadata, text, frames) until the classes are balanced.
Correct Answer: A

Correct Options Analysis:
- A is Correct: This is the correct multimodal imbalance strategy. Each data type requires its own specific augmentation technique: SMOTE is valid for continuous numeric features, back-translation/synonym replacement is valid for text, and geometric/color transformations are valid for images. This generates new variation across all modalities without simple duplication.

Distractor Analysis:
- B is Incorrect: This option applies the wrong technique to the wrong modality. SMOTE cannot be applied to raw text, back-translation cannot be applied to images, and image augmentation cannot be applied to numeric metadata.
- C is Incorrect: Undersampling the numeric metadata breaks the link between the modalities (you'd have to drop the associated text and frames too), and dropping text features entirely loses valuable information.
- D is Incorrect: Simply duplicating the entire multimodal record leads to severe overfitting, as the model will memorize the exact combination of features, text, and frames for the minority class.

> Key Takeaway: When resolving class imbalance in multimodal datasets, apply modality-specific augmentation techniques (e.g., SMOTE for numeric, back-translation for text, rotations for images) simultaneously to generate diverse synthetic minority samples.
### Question 10 - Cost-Effective Imbalance Handling on AWS

An e-commerce company is building a SageMaker pipeline to detect fake reviews. The dataset is heavily imbalanced (99% real, 1% fake). The company wants to resolve the class imbalance to improve the model's F1-score. Due to budget constraints, the CTO has mandated that the solution must be the MOST cost-effective and avoid provisioning additional compute resources for heavy data processing ETL jobs.

Which approach is the MOST appropriate under these constraints?

- A) Use AWS Glue DataBrew to profile, clean, and oversample the minority class, storing the balanced dataset in Amazon S3 before training.
- B) Spin up a large Amazon EMR cluster to process the dataset and apply SMOTE across the entire 1TB dataset before training.
- C) Configure the SageMaker built-in algorithm to use class weighting (e.g., scale_pos_weight) during the training job.
- D) Use AWS Lambda to iterate through the S3 dataset and duplicate the minority class records in place.
Correct Answer: C

Correct Options Analysis:
- C is Correct: Configuring class weights directly in the SageMaker training algorithm (like XGBoost's scale_pos_weight or Linear Learner's binary_classifier_model_selection_criteria) adds zero operational overhead and no additional compute costs. It modifies the loss function during the existing training run, making it the most cost-effective method to handle imbalance.

Distractor Analysis:
- A is Incorrect: AWS Glue DataBrew requires provisioning DPU (Data Processing Units) resources to run profile and transformation jobs, incurring additional compute costs that violate the budget constraint.
- B is Incorrect: Spinning up an Amazon EMR cluster to process a 1TB dataset introduces significant compute costs and operational overhead for ETL, directly violating the cost-effectiveness and "no heavy data processing" constraints.
- D is Incorrect: Using AWS Lambda to process a large dataset in S3 is an anti-pattern due to the 15-minute execution timeout and memory limits. It would require complex orchestration and still incurs compute costs.

> Key Takeaway: The most cost-effective and lowest-overhead method to handle class imbalance on AWS is to leverage algorithm-level hyperparameters (like class weights) natively supported by SageMaker built-in algorithms, avoiding expensive ETL and data processing compute costs entirely.