WGU D682 Task 2 exam - Artificial
Intelligence Optimization for Computer
Scientists | AI Model Optimization, Python,
GitLab, RMSE & R² | 2026/2027 Updated
Practice Question Bank & Answer Rationale
THIS PACK CONTAINS
99 exam-style multiple-choice questions. Each question includes the correct answer and a complete rationale
for focused revision.
COVERAGE
This exam assesses applied competencies in optimizing AI/ML models, evaluating regression performance
with RMSE and R², managing experiments and code with GitLab CI/CD, and implementing optimization
workflows in Python. It emphasizes practical, tool-based problem solving aligned with modern MLOps
practices.
STUDY GUIDE
Recommended duration: 2.5 hours. Passing target: 80% (Competent) - A+ target 95%.
HIGHP - Page 1 of 32
,1. A regression model achieves RMSE = 0 on the training set but RMSE = 18.4 on a
held-out test set. Which conclusion is most defensible?
[ ] A. The model has high bias and needs more features.
[ ] B. The model is overfitting and should be regularized or simplified.
[ ] C. The test set is mislabeled because RMSE cannot be zero on training data.
[ ] D. R² on the test set must also be 1.0 because training error is zero.
CORRECT: B. The model is overfitting and should be regularized or simplified.
A zero training RMSE with large test RMSE is the classic signature of overfitting (high variance).
Regularization, simplification, or more data are appropriate remedies. High bias would show large errors on
both sets, and R² on test would not be 1.0.
2. In a GitLab CI/CD pipeline for an ML project, which job configuration best ensures that a
model training script only runs after unit tests pass?
[ ] A. Define both jobs in the same stage and rely on alphabetical execution order.
[ ] B. Use `needs: [unit_tests]` in the training job to create an explicit dependency.
[ ] C. Set `when: always` on the training job so it runs regardless of test outcome.
[ ] D. Place the training job in the `.pre` stage to guarantee it runs first.
CORRECT: B. Use `needs: [unit_tests]` in the training job to create an explicit dependency.
The `needs` keyword creates a directed acyclic graph (DAG) dependency, ensuring the training job waits for
the unit test job to succeed. Same-stage jobs run in parallel, `when: always` ignores failures, and `.pre` runs
before all other stages, which is the opposite of what is needed.
3. A dataset has a target variable with a strong linear relationship to one feature, but the
model's R² is 0.15. Which action is most likely to improve R² without data leakage?
[ ] A. Add polynomial features of the existing feature and retrain.
[ ] B. Remove outliers from the test set only.
[ ] C. Standardize the target variable before training.
[ ] D. Increase the learning rate of the optimizer.
CORRECT: A. Add polynomial features of the existing feature and retrain.
If the relationship is nonlinear (e.g., quadratic), adding polynomial features allows a linear model to capture it,
increasing R². Removing test outliers is data leakage and unethical; target standardization does not change
R²; learning rate affects convergence, not model capacity.
4. Which Python snippet correctly computes RMSE using scikit-learn for predictions
`y_pred` and true values `y_true`?
[ ] A. `np.sqrt(mean_squared_error(y_true, y_pred))`
[ ] B. `mean_squared_error(y_true, y_pred) ** 2`
HIGHP - Page 2 of 32
, [ ] C. `np.mean(np.abs(y_true - y_pred))`
[ ] D. `r2_score(y_true, y_pred) ** 0.5`
CORRECT: A. `np.sqrt(mean_squared_error(y_true, y_pred))`
RMSE is the square root of the mean squared error, correctly computed as
`np.sqrt(mean_squared_error(...))`. Option B squares MSE instead of taking the root; C computes MAE; D
takes the square root of R², which is not RMSE.
5. A team uses GitLab and wants to track model experiments, including hyperparameters
and metrics, alongside code. Which GitLab feature is most appropriate?
[ ] A. GitLab Container Registry
[ ] B. GitLab MLflow integration (or GitLab Experiments)
[ ] C. GitLab Pages
[ ] D. GitLab Snippets
CORRECT: B. GitLab MLflow integration (or GitLab Experiments)
GitLab offers experiment tracking via MLflow integration or the GitLab Experiments feature, which logs
parameters and metrics. Container Registry stores images, Pages hosts static sites, and Snippets share
code fragments-none provide experiment tracking.
6. When optimizing a neural network with stochastic gradient descent, which change is
most likely to reduce overfitting without increasing training time significantly?
[ ] A. Increase the number of epochs.
[ ] B. Add dropout layers with a rate of 0.5.
[ ] C. Increase the learning rate by 10x.
[ ] D. Remove all regularization from the loss function.
CORRECT: B. Add dropout layers with a rate of 0.5.
Dropout randomly deactivates neurons during training, acting as a regularizer that reduces overfitting with
minimal computational overhead. More epochs and higher learning rates can worsen overfitting or destabilize
training; removing regularization increases overfitting.
7. A model's R² is negative on a test set. What does this indicate?
[ ] A. The model is perfectly predicting the target.
[ ] B. The model performs worse than a horizontal line predicting the mean.
[ ] C. The model's RMSE is zero.
[ ] D. The test set is too small to compute R².
CORRECT: B. The model performs worse than a horizontal line predicting the mean.
R² can be negative when the model's predictions are worse than simply using the mean of the true values.
HIGHP - Page 3 of 32
, This often happens with severe overfitting or when the test distribution differs from training. Zero RMSE
would give R²=1, and test size does not cause negative R².
8. In a GitLab CI pipeline, which `.gitlab-ci.yml` snippet correctly caches Python
dependencies to speed up subsequent jobs?
[ ] A. `cache: { key: '$CI_COMMIT_REF_SLUG', paths: ['.venv/'] }`
[ ] B. `artifacts: { paths: ['.venv/'] }`
[ ] C. `only: [main]`
[ ] D. `script: pip install -r requirements.txt`
CORRECT: A. `cache: { key: '$CI_COMMIT_REF_SLUG', paths: ['.venv/'] }`
The `cache` keyword with a key and paths stores dependencies between pipeline runs. `artifacts` are for
passing files between jobs in the same pipeline, `only` restricts job execution, and the script command
installs but does not cache.
9. A data scientist uses `GridSearchCV` with 5-fold cross-validation to tune
hyperparameters. What is the primary benefit of this approach?
[ ] A. It guarantees the best possible model on unseen data.
[ ] B. It reduces the risk of overfitting to a single validation split.
[ ] C. It eliminates the need for a separate test set.
[ ] D. It automatically performs feature selection.
CORRECT: B. It reduces the risk of overfitting to a single validation split.
Cross-validation averages performance across multiple folds, providing a more robust estimate and reducing
the chance of overfitting to one validation set. It does not guarantee generalization, replace a test set, or
perform feature selection by default.
10. Which scenario best illustrates data leakage in an AI optimization project?
[ ] A. Normalizing features using statistics computed from the entire dataset before splitting.
[ ] B. Using a separate validation set for early stopping.
[ ] C. Applying data augmentation only to the training set.
[ ] D. Tuning hyperparameters on a validation set.
CORRECT: A. Normalizing features using statistics computed from the entire dataset before splitting.
Computing normalization statistics on the full dataset before splitting leaks information from the test set into
training. The other options are standard, leak-free practices: early stopping uses validation data,
augmentation applies only to training, and hyperparameter tuning uses validation data.
HIGHP - Page 4 of 32
Intelligence Optimization for Computer
Scientists | AI Model Optimization, Python,
GitLab, RMSE & R² | 2026/2027 Updated
Practice Question Bank & Answer Rationale
THIS PACK CONTAINS
99 exam-style multiple-choice questions. Each question includes the correct answer and a complete rationale
for focused revision.
COVERAGE
This exam assesses applied competencies in optimizing AI/ML models, evaluating regression performance
with RMSE and R², managing experiments and code with GitLab CI/CD, and implementing optimization
workflows in Python. It emphasizes practical, tool-based problem solving aligned with modern MLOps
practices.
STUDY GUIDE
Recommended duration: 2.5 hours. Passing target: 80% (Competent) - A+ target 95%.
HIGHP - Page 1 of 32
,1. A regression model achieves RMSE = 0 on the training set but RMSE = 18.4 on a
held-out test set. Which conclusion is most defensible?
[ ] A. The model has high bias and needs more features.
[ ] B. The model is overfitting and should be regularized or simplified.
[ ] C. The test set is mislabeled because RMSE cannot be zero on training data.
[ ] D. R² on the test set must also be 1.0 because training error is zero.
CORRECT: B. The model is overfitting and should be regularized or simplified.
A zero training RMSE with large test RMSE is the classic signature of overfitting (high variance).
Regularization, simplification, or more data are appropriate remedies. High bias would show large errors on
both sets, and R² on test would not be 1.0.
2. In a GitLab CI/CD pipeline for an ML project, which job configuration best ensures that a
model training script only runs after unit tests pass?
[ ] A. Define both jobs in the same stage and rely on alphabetical execution order.
[ ] B. Use `needs: [unit_tests]` in the training job to create an explicit dependency.
[ ] C. Set `when: always` on the training job so it runs regardless of test outcome.
[ ] D. Place the training job in the `.pre` stage to guarantee it runs first.
CORRECT: B. Use `needs: [unit_tests]` in the training job to create an explicit dependency.
The `needs` keyword creates a directed acyclic graph (DAG) dependency, ensuring the training job waits for
the unit test job to succeed. Same-stage jobs run in parallel, `when: always` ignores failures, and `.pre` runs
before all other stages, which is the opposite of what is needed.
3. A dataset has a target variable with a strong linear relationship to one feature, but the
model's R² is 0.15. Which action is most likely to improve R² without data leakage?
[ ] A. Add polynomial features of the existing feature and retrain.
[ ] B. Remove outliers from the test set only.
[ ] C. Standardize the target variable before training.
[ ] D. Increase the learning rate of the optimizer.
CORRECT: A. Add polynomial features of the existing feature and retrain.
If the relationship is nonlinear (e.g., quadratic), adding polynomial features allows a linear model to capture it,
increasing R². Removing test outliers is data leakage and unethical; target standardization does not change
R²; learning rate affects convergence, not model capacity.
4. Which Python snippet correctly computes RMSE using scikit-learn for predictions
`y_pred` and true values `y_true`?
[ ] A. `np.sqrt(mean_squared_error(y_true, y_pred))`
[ ] B. `mean_squared_error(y_true, y_pred) ** 2`
HIGHP - Page 2 of 32
, [ ] C. `np.mean(np.abs(y_true - y_pred))`
[ ] D. `r2_score(y_true, y_pred) ** 0.5`
CORRECT: A. `np.sqrt(mean_squared_error(y_true, y_pred))`
RMSE is the square root of the mean squared error, correctly computed as
`np.sqrt(mean_squared_error(...))`. Option B squares MSE instead of taking the root; C computes MAE; D
takes the square root of R², which is not RMSE.
5. A team uses GitLab and wants to track model experiments, including hyperparameters
and metrics, alongside code. Which GitLab feature is most appropriate?
[ ] A. GitLab Container Registry
[ ] B. GitLab MLflow integration (or GitLab Experiments)
[ ] C. GitLab Pages
[ ] D. GitLab Snippets
CORRECT: B. GitLab MLflow integration (or GitLab Experiments)
GitLab offers experiment tracking via MLflow integration or the GitLab Experiments feature, which logs
parameters and metrics. Container Registry stores images, Pages hosts static sites, and Snippets share
code fragments-none provide experiment tracking.
6. When optimizing a neural network with stochastic gradient descent, which change is
most likely to reduce overfitting without increasing training time significantly?
[ ] A. Increase the number of epochs.
[ ] B. Add dropout layers with a rate of 0.5.
[ ] C. Increase the learning rate by 10x.
[ ] D. Remove all regularization from the loss function.
CORRECT: B. Add dropout layers with a rate of 0.5.
Dropout randomly deactivates neurons during training, acting as a regularizer that reduces overfitting with
minimal computational overhead. More epochs and higher learning rates can worsen overfitting or destabilize
training; removing regularization increases overfitting.
7. A model's R² is negative on a test set. What does this indicate?
[ ] A. The model is perfectly predicting the target.
[ ] B. The model performs worse than a horizontal line predicting the mean.
[ ] C. The model's RMSE is zero.
[ ] D. The test set is too small to compute R².
CORRECT: B. The model performs worse than a horizontal line predicting the mean.
R² can be negative when the model's predictions are worse than simply using the mean of the true values.
HIGHP - Page 3 of 32
, This often happens with severe overfitting or when the test distribution differs from training. Zero RMSE
would give R²=1, and test size does not cause negative R².
8. In a GitLab CI pipeline, which `.gitlab-ci.yml` snippet correctly caches Python
dependencies to speed up subsequent jobs?
[ ] A. `cache: { key: '$CI_COMMIT_REF_SLUG', paths: ['.venv/'] }`
[ ] B. `artifacts: { paths: ['.venv/'] }`
[ ] C. `only: [main]`
[ ] D. `script: pip install -r requirements.txt`
CORRECT: A. `cache: { key: '$CI_COMMIT_REF_SLUG', paths: ['.venv/'] }`
The `cache` keyword with a key and paths stores dependencies between pipeline runs. `artifacts` are for
passing files between jobs in the same pipeline, `only` restricts job execution, and the script command
installs but does not cache.
9. A data scientist uses `GridSearchCV` with 5-fold cross-validation to tune
hyperparameters. What is the primary benefit of this approach?
[ ] A. It guarantees the best possible model on unseen data.
[ ] B. It reduces the risk of overfitting to a single validation split.
[ ] C. It eliminates the need for a separate test set.
[ ] D. It automatically performs feature selection.
CORRECT: B. It reduces the risk of overfitting to a single validation split.
Cross-validation averages performance across multiple folds, providing a more robust estimate and reducing
the chance of overfitting to one validation set. It does not guarantee generalization, replace a test set, or
perform feature selection by default.
10. Which scenario best illustrates data leakage in an AI optimization project?
[ ] A. Normalizing features using statistics computed from the entire dataset before splitting.
[ ] B. Using a separate validation set for early stopping.
[ ] C. Applying data augmentation only to the training set.
[ ] D. Tuning hyperparameters on a validation set.
CORRECT: A. Normalizing features using statistics computed from the entire dataset before splitting.
Computing normalization statistics on the full dataset before splitting leaks information from the test set into
training. The other options are standard, leak-free practices: early stopping uses validation data,
augmentation applies only to training, and hyperparameter tuning uses validation data.
HIGHP - Page 4 of 32