
Explanation:
The correct code snippet for saving the trained model to the Databricks MLflow tracking server is option D. Here's why:
mlflow.start_run(): Initiates a new run in the MLflow tracking server, allowing the model to be associated with a specific experiment for lineage tracking.mlflow.spark.log_model(trained_model, “model“): Logs the trained Spark MLlib model as an artifact named “model“ within the current run, making it easily accessible and identifiable later.mlflow.end_run(): Marks the end of the run, capturing all logged metrics, parameters, and artifacts for future reference.Other options have issues:
logModel instead of log_model) and won't execute.Option D ensures the model is properly logged to the MLflow tracking server within a specific run, facilitating future access and analysis. Remember to replace placeholders with actual model objects and desired artifact names.
Ultimate access to all questions.
A data scientist is training a machine learning model using Spark MLlib in a Databricks notebook. They aim to save the trained model to the Databricks MLflow tracking server for future use. Which of the following code snippets should they use?
A
mlflow.log_model(trained_model, “model“)
B
mlflow.spark.save_model(trained_model, “model“)
C
mlflow.spark.logModel(trained_model, “model“)
D
mlflow.start_run()mlflow.spark.log_model(trained_model, “model“)mlflow.end_run()
No comments yet.