‹ All MLA-C01 questions

MLA-C01 Practice Question 66: XGBoost Class Weighting

AWS Certified Machine Learning Engineer – Associate (MLA-C01) · Test 7 · question 6 of 10

Model Developmentmedium

A telecom company trains the SageMaker AI built-in XGBoost algorithm with the binary:logistic objective to predict which customers will port their number to a competitor. Only 2% of the 500,000 training examples are positive, about 1 positive for every 49 negatives. The model rarely predicts the positive class. The team wants training to account for the imbalance directly, without resampling the data or changing the dataset in any way.

Which hyperparameter change should the team make?

Select one answer
Show answer and explanation

Answer:

  • B. Set scale_pos_weight to about 49, the ratio of negative to positive examples, so that positive examples carry more weight in training

scale_pos_weight controls the balance of positive and negative weights and is meant for unbalanced classes. AWS suggests a typical value of sum(negative cases) / sum(positive cases), which is about 49 here. Each positive example then counts roughly as much as all its negatives combined in the loss, so the trees stop ignoring the minority class, and the dataset stays untouched (option B).

- A is wrong because eval_metric only changes how validation performance is *reported*, and what early stopping watches. The loss that builds the trees is unchanged, so the imbalance is still in the training signal. - C is wrong because deeper trees add capacity without reweighting anything. They mostly memorize noise and overfit, and still favor the dominant class. - D is wrong because base_score sets only the initial prediction that boosting starts from. The majority class still dominates the gradients in every later round.

Reference: XGBoost hyperparameters

Practice Test 7 ›

Study guides for MLA-C01