Question 16
Domain 2: Explore data and run experimentsYou need to log metrics data from your job runs using MLflow. Should you use `mlflow.log_metric()` to record values such as accuracy or loss during execution?
Correct answer: B
Explanation
Yes. MLflow provides `mlflow.log_metric()` to record metric names and values during a run, which is why it is used for values like accuracy or loss. It can be called repeatedly so you can track how a metric changes over time.
Why each option is right or wrong
A. No. MLflow cannot record numeric metrics from runs; it only supports logging parameters and artifacts.
B. Yes. Use `mlflow.log_metric()` to log metric names and values, and call it repeatedly if you want to track changes over time.
MLflow’s tracking API includes `mlflow.log_metric()` for recording numeric run metrics, and the function is designed to accept a metric key and value during execution. In practice, repeated calls with the same metric name are allowed and are stored as separate metric points, which is how you capture a series such as accuracy or loss over training steps or epochs.