Course menuMLA-C02

Exams / MLA-C02 / Study guide / Bias and class imbalance

Bias and class imbalance: MLA-C02 study notes and practice questions

What to know about Bias and class imbalance for the MLA-C02 exam, from the Data Preparation for ML and AI domain (28% of the exam guide), then 3 free questions to test it. Part of the MLA-C02 study guide.

Last verified against current AWS documentation ·How we write our questions

What to know for the exam

These questions describe a rare class (fraud, defects) or an unfair outcome across groups and ask how to measure or fix it.

Class imbalance

  • With 1% fraud, a model that always says “not fraud” is 99% accurate, so use precision, recall, F1, PR AUC instead of accuracy.
  • Stratified splits keep the real class ratio in training, validation and test sets.
  • Class weights (such as scale_pos_weight in XGBoost) make the loss pay more attention to the rare class without changing the data.
  • Resampling: oversample the minority, undersample the majority, or create synthetic examples with SMOTE. Do it only on the training set, after splitting, so evaluation reflects reality.
  • Threshold tuning trades precision against recall for the business cost.
  • Collect more minority examples where possible.

Measuring bias with SageMaker Clarify

Stage What it measures Example metrics
Pre-training The dataset before any model exists Class Imbalance (CI) across a facet (such as age group), Difference in Proportions of Labels (DPL)
Post-training The trained model’s predictions Difference in Positive Proportions in Predicted Labels (DPPL), Disparate Impact (DI), differences in recall or accuracy across groups
  • A facet is the attribute you check, such as gender or age band.
  • Reports are written to S3 and appear in SageMaker Studio.
  • Model Monitor bias drift runs the post-training checks on production data on a schedule.

Reducing bias

  • Fix sampling so groups are represented.
  • Remove proxies for protected attributes when appropriate.
  • Rebalance or reweight training data, and review the threshold per use case.
  • Document decisions in model cards.

Common traps

  • Reporting accuracy on a highly imbalanced dataset.
  • Oversampling before splitting, which leaks copies into the test set.
  • Pre-training metrics to judge the model’s decisions. Use post-training metrics.

Try the 3 practice questions

A regional bank is training a small-business loan approval model. Applications from one age group make up only 9 percent of the training data, and the team has not yet checked whether the dataset itself favors any group.

The bank's ML platform team already runs SageMaker Clarify jobs for its other credit models. The new check must measure dataset-level bias before any model is trained, using the protected attribute in the data, and store the results with the training data for the model-risk team.

Which approach meets these requirements?

Choose one answer.

  1. A. Run a Clarify job that computes SHAP values on the trained model, and review which features drive each prediction.
  2. B. Run a SageMaker Clarify processing job that computes pre-training bias metrics, such as class imbalance and difference in proportions of labels, for the age-group facet.
  3. C. Generate a Glue DataBrew profile of the applications, and review the column distributions for the age-group field with the model-risk team.
  4. D. Set up a Model Monitor data quality monitor on the endpoint after deployment and review its violations weekly.
Show the answer and explanation

Answer: B

  • A. Wrong: SHAP values explain a trained model's predictions, which is a different task. The stem asks for dataset-level bias before training.
  • B. Right: Correct. Clarify pre-training bias metrics measure the dataset itself, including class imbalance and label proportions across a facet, and the job writes a report to S3. This fits the requirement to check before training. Learn more: Pre-training data bias with SageMaker Clarify (opens in a new tab)
  • C. Wrong: A profile shows distributions but does not compute bias metrics for a facet or label proportions. The team needs the bias measures for the model-risk review.
  • D. Wrong: This runs after the model is deployed and checks incoming data against a baseline, so it cannot check the training dataset before training. It also does not compute the bias metrics.

Explanation

Clarify pre-training bias metrics measure the dataset before training, including class imbalance and label proportions across a protected group, and the results are written to S3 for review. SHAP explains trained predictions, DataBrew profiles without bias metrics, and Model Monitor runs only after deployment.

Study

A pet insurer is training a claims-fraud model. Only about 0.3 percent of its historical claims are confirmed as fraud, and the team wants a model whose predicted probabilities are still meaningful for underwriting.

The evaluation sets must represent the real claim mix so that precision and recall reflect production. The team also wants no synthetic records in the training data, because the claims team has to audit every training example.

Which approach meets these requirements?

Choose one answer.

  1. A. Undersample the legitimate claims until the classes are balanced in the full dataset, then split the balanced data into training, validation and test sets.
  2. B. Generate synthetic fraud claims with SMOTE and add them to the training set, keeping the validation and test sets unchanged.
  3. C. Split into stratified training, validation and test sets at the real fraud rate, and set class weights only in the training set.
  4. D. Duplicate the fraud claims in the training set until the classes are equal, then split the data randomly into the three sets.
Show the answer and explanation

Answer: C

  • A. Wrong: Balancing before the split changes the evaluation sets, so precision and recall no longer reflect the real claim mix. Undersampling also discards many legitimate examples the team could learn from.
  • B. Wrong: SMOTE creates synthetic examples, which the claims team has ruled out for audit reasons. Synthetic records also distort the probabilities the underwriters rely on.
  • C. Right: Correct. A stratified split keeps the real 0.3 percent rate in every set, so evaluation matches production, and class weights in training change the loss without adding records. No synthetic examples are created.
  • D. Wrong: Duplicating before a random split places copies of the same claim in training and evaluation, which inflates the test scores. The option also changes the data the auditors review.

Explanation

Stratified splits keep the real fraud rate in every evaluation set, while class weights in the training loss handle the imbalance without creating records. Balancing or duplicating before the split distorts evaluation, and SMOTE adds synthetic records the audit rules out.

Study

A regional bank has deployed a credit-decision model. Applicants from one protected group are approved far less often than others, and the model-risk team wants to measure the bias in the model's predictions rather than in the training labels.

The team already uses SageMaker Clarify for its pre-training analysis. The new check must compare outcomes across groups using the model's predicted labels, on the same bias facet as that analysis.

Which metric should the team use?

Choose one answer.

  1. A. Class imbalance, computed on the training labels before the model was trained, because it measures how often each age group appears in the dataset.
  2. B. SHAP feature importance for the protected attribute, because a large importance value shows the model is biased.
  3. C. Accuracy of the model computed on the test set, broken down only by overall error rate and not by group.
  4. D. Difference in positive proportions in predicted labels, computed by Clarify as a post-training bias metric on the model's predictions.
Show the answer and explanation

Answer: D

  • A. Wrong: Class imbalance is a pre-training measure of how often each group appears in the dataset. It does not use the model's predictions, so it cannot show how the model treats each group.
  • B. Wrong: SHAP shows how features contribute to predictions, which is useful for explanations. It is not a bias metric comparing outcome rates across groups.
  • C. Wrong: Overall accuracy hides the group-level outcome gap the team needs to measure. The stem asks for a comparison across the protected groups.
  • D. Right: Correct. This post-training metric compares the rate of positive predictions between groups, which is the outcome the team needs to measure. Clarify computes it from predictions on the bank's chosen facet. Learn more: Post-training data and model bias metrics (opens in a new tab)

Explanation

Post-training bias metrics use the model's predictions. Difference in positive proportions in predicted labels compares positive outcome rates across groups, which exposes the approval gap. Pre-training metrics describe the data, SHAP explains predictions, and overall accuracy hides group differences.

Study

Want more on Bias and class imbalance? The 5 full-length practice sets have 5 more Bias and class imbalance questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets

Study Bias and class imbalance

More Data Preparation for ML and AI topics