Certified Machine Learning Professional Exam QuestionsBrowse all questions from this exam

Certified Machine Learning Professional 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?

Show Answer
Correct Answer: AC

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

3 comments
Sign in to comment
BokNinjaOption: C
Dec 19, 2023

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)

random_data_guyOption: C
Dec 27, 2023

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)

hugodscarvalhoOption: C
Jan 27, 2024

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