Logging MLflow Dictionary Artifacts in Azure Machine Learning
Short answer
C mlflow.log_metrics(my_dict)
Question
Key Takeaways
Tests knowledge of MLflow tracking functions; the trap is confusing metric logging with parameter or artifact logging, though the question's use of 'artifacts' is technically imprecise terminology for metrics.
This question tests the correct MLflow Python API syntax for logging multiple key-value pairs as metrics. The community consensus confirms that mlflow.log_metrics() is the standard method for handling dictionary inputs in ML experiments.
Common mistake: Option B (log_metric) is incorrect because it expects a single value, not a dictionary. Option A (log_input) is for input data tracking, and D (log_text) is for raw text strings.
Expert Analysis
Why the Answer Is Correct
The mlflow.log_metrics() function accepts a dictionary of key-value pairs where keys are metric names and values are numeric scores. This allows efficient batch logging of multiple evaluation results (e.g., accuracy, loss) in a single call, which matches the requirement to log a dictionary.
Why the Other Options Are Wrong
mlflow.log_metric takes a single string key and float value, making it unsuitable for dictionaries. mlflow.log_input is used to track dataset versions, not model performance metrics. mlflow.log_text logs arbitrary text content, not structured numerical metrics.
Community Comment Notes
Comment [1] provides official documentation examples showing mlflow.log_metrics(metrics) with a dictionary. Comment [3] correctly notes that if these were hyperparameters, log_params would be appropriate, but since they are typically experiment outputs, log_metrics is the best fit among the choices.
Official Reference
https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.log_metrics
This link opens the official vendor documentation in a new tab.
Exam Strategy
Distinguish between MLflow functions by their data type: log_metric/log_metrics for numbers, log_param/log_params for strings/configs, and log_artifact for files. Always check if the input is a single value or a collection to choose between singular and plural method names.
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 4 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 4
-
avinyc 👍 2 Answered CRef - https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.log_input import mlflow metrics = {"mse": 2500.00, "rmse": 50.00} # Log a batch of metrics with mlflow.start_run(): mlflow.log_metrics(metrics) # Log a batch of metrics in async fashion. with mlflow.start_run(): mlflow.log_metrics(metrics, synchronous=False)
-
jl420 👍 2Answer is C - mlflow.log_metrics(my_dict) Explanation: In MLflow, when you want to log dictionary-type artifacts that contain multiple metrics, you should use the mlflow.log_metrics() method. This method allows you to log multiple key-value pairs (i.e., a dictionary) as metrics.
-
AzureGeek79 👍 2the correct answer is log_params which is not included in the available options
-
jefimija 👍 1log_artifact maybe?
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.