Complete the code to register a model named 'my_model' in MLflow. Assume 'model' is a scikit-learn model and registered_model_name='my_model' is used.
import mlflow mlflow.[1].log_model(model, 'my_model', registered_model_name='my_model')
The mlflow.sklearn module is used to log scikit-learn models to MLflow. Specifying registered_model_name='my_model' registers it in the model registry.
Complete the code to load a registered model named 'my_model' from MLflow.
import mlflow model = mlflow.pyfunc.load_model(model_uri='models:/[1]/1')
The model URI must match the registered model name exactly, which is 'my_model' here.
Fix the error in the code to transition a model version to 'Production' stage.
from mlflow.tracking import MlflowClient client = MlflowClient() client.[1](name='my_model', version=1, stage='Production')
The correct method to change a model version's stage is transition_model_version_stage.
Fill both blanks to create a client and list all registered models.
from mlflow.tracking import [1] client = [2]() models = client.list_registered_models()
The MlflowClient class is used to interact with the model registry, including listing models.
Fill all three blanks to register a model, transition its stage, and load it.
import mlflow client = mlflow.tracking.[1]() client.transition_model_version_stage(name='my_model', version=1, stage=[2]) model = mlflow.pyfunc.load_model(model_uri='models:/my_model/[3]')
Use MlflowClient to transition the model stage to 'Production' and load the model from that stage.