
Explanation:
The solution does NOT meet the goal because it uses run.log('AUC', auc) without first obtaining the Azure ML run context. For Hyperdrive to optimize hyperparameters based on the AUC metric, the metric must be logged using the Azure ML run instance (e.g., run = Run.get_context() followed by run.log('AUC', auc)). The community discussion strongly supports this, with the top-voted comment (20 upvotes) emphasizing that logging with the Azure ML run context is required for Hyperdrive optimization. While the code correctly calculates AUC using roc_auc_score, the missing run context initialization means Hyperdrive cannot access the metric for hyperparameter tuning. Thus, the answer is 'No' (B).
Ultimate access to all questions.
You are using Azure Machine Learning to train a classification model and have configured HyperDrive to optimize the AUC metric. You plan to run a script that trains a random forest model, where the validation data labels are stored in a variable named y_test and the predicted probabilities are stored in a variable named y_predicted.
You need to add logging to the script to enable Hyperdrive to optimize hyperparameters for the AUC metric.
Proposed Solution: Run the following code:
from sklearn.metrics import roc_auc_score
auc = roc_auc_score(y_test, y_predicted)
run.log('AUC', auc)
from sklearn.metrics import roc_auc_score
auc = roc_auc_score(y_test, y_predicted)
run.log('AUC', auc)
Does the solution meet the goal?

A
Yes
B
No
No comments yet.