
Answer-first summary for fast verification
Answer: `mlflow.log_artifact(importance_df, "importance_df")`
The correct answer is `mlflow.log_artifact(importance_df, "importance_df")`. Here's why: - `mlflow.log_artifact()` is the correct function for logging artifacts (such as files or directories) with an MLflow run. - `importance_df` is a pandas DataFrame, which qualifies as an artifact. - The name "importance_df" is arbitrary and can be chosen to help identify the artifact later. The other options are incorrect because: - `mlflow.log_metric()` is intended for logging scalar metrics (e.g., accuracy, loss), not artifacts. - `importance_path` refers to the path of the CSV file, not the DataFrame itself. Thus, the appropriate code to log the feature importance values with the MLflow run is: ```python mlflow.log_artifact(importance_df, "importance_df") ```
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A Data Scientist is working on calculating the importance of features as part of an MLFlow Run. The feature importance values are stored in a pandas dataframe named importance_df and are being written as a CSV to a DBFS location at importance_path. They wish to log these values with their active MLFlow run. Which of the following lines of code should the data scientist use to log the feature importance values with their MLFlow run?
Choose only ONE best answer.
A
mlflow.log_artifact(importance_df)
B
mlflow.log_metric(importance_path, "importance.csv")
C
mlflow.log_artifact(importance_df, "importance_df")
D
mlflow.log_metric(importance_path, "importance.csv")
E
mlflow.log_metric(importance_df, "importance_df")
No comments yet.