Exam Certified Machine Learning Professional All QuestionsBrowse all questions from this exam
Question 20

A data scientist has developed a model model and computed the RMSE of the model on the test set. They have assigned this value to the variable rmse. They now want to manually store the RMSE value with the MLflow run.

They write the following incomplete code block:

Which of the following lines of code can be used to fill in the blank so the code block can successfully complete the task?

    Correct Answer: C

    The appropriate function to store the RMSE value in MLflow is 'log_metric'. This function is used to log metrics, which are key-value pairs where the value is a numerical metric. This suits the requirement of logging the RMSE, a numerical value, associated with a model run. Therefore, the correct line of code to log the RMSE value is 'mlflow.log_metric("rmse", rmse)'.

Discussion
hugodscarvalhoOption: C

RMSE is a metric so we should use the inbuilt mlflow.log_metric(). Doc: https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.log_metric

random_data_guyOption: C

https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.log_metric import mlflow # Log a metric with mlflow.start_run(): mlflow.log_metric("mse", 2500.00)

BokNinjaOption: C

C. import numpy as np from sklearn.metrics import mean_squared_error import mlflow # Assuming 'actual' is your array of actual values and 'pred' is your array of predicted values actual = ... pred = ... # Calculate RMSE rmse = np.sqrt(mean_squared_error(actual, pred)) # Log RMSE metric in MLflow mlflow.log_metric("rmse", rmse)