Courseiva
Model Development →hardMultiple Choice

Databricks-ML-Pro Model Development Practice Question

A machine learning engineer is building a model on Databricks and wants to use MLflow to track experiments. They need to log a custom metric that is calculated during training but is not automatically captured by `mlflow.autolog()`. They also want to ensure that the metric is associated with the correct run. Which code snippet should they use inside their training script?

⚠ Common exam trap

Many exam-takers confuse the different MLflow logging APIs and using one meant for parameters, tags, or artifacts instead of metrics.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

`mlflow.log_metric("custom_metric", value)` after starting a run with `mlflow.start_run()`.

To log a custom metric in MLflow, the correct API is `mlflow.log_metric`, which records a scalar value associated with the current run. It must be called within an active run context. This allows the metric to be tracked, visualized, and compared across runs. Other APIs like `log_param`, `set_tag`, or `log_artifact` serve different purposes and would not properly record the metric.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    `mlflow.log_metric("custom_metric", value)` after starting a run with `mlflow.start_run()`.

    Why this is correct

    `mlflow.log_metric` is the correct API to log a custom metric manually. It must be called within an active MLflow run, typically started with `mlflow.start_run()`. This ensures the metric is associated with that specific run. This approach is standard for logging metrics not captured by autologging, such as custom evaluation scores or business-specific KPIs.

  • ✗

    `mlflow.set_tag("custom_metric", value)` after starting a run with `mlflow.start_run()`.

    Why it's wrong here

    `mlflow.set_tag` is used to set tags, which are key-value pairs for metadata, not numerical metrics. Tags are not visualized as metrics in the MLflow UI and cannot be used for plotting or comparison. While tags can store arbitrary strings, they are not suitable for tracking a custom metric that needs to be analyzed over time.

  • ✗

    `mlflow.log_artifact("custom_metric", value)` after starting a run with `mlflow.start_run()`.

    Why it's wrong here

    `mlflow.log_artifact` is used to log files as artifacts, such as model files or plots. It does not accept a metric name and value pair. Using it for a metric would not store the metric in the metrics store, and it would not appear in the metrics section of the MLflow UI. This method is incorrect for logging scalar metrics.

  • ✗

    `mlflow.log_param("custom_metric", value)` after starting a run with `mlflow.start_run()`.

    Why it's wrong here

    `mlflow.log_param` is used to log parameters, not metrics. Parameters are typically input values that do not change during a run, such as hyperparameters. Using `log_param` for a metric would misclassify the value, and it would not be tracked as a metric in the MLflow UI, making it difficult to compare across runs. Metrics should be logged with `log_metric`.

About these practice questions

Courseiva writes every Databricks-ML-Pro question from scratch — 300 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Databricks exam blueprint

This Databricks-ML-Pro practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-ML-Pro exam.