Register models
Register and retrieve models using the MLflow Model Registry from a BullSequana AI dev environment.
The MLflow Model Registry is a central store for versioned models. You can register a trained model from a dev environment, then retrieve any version of it in another dev environment or application. All registered models are accessible to every user on the platform.
Register a model
To register a model, log it as an artifact during a run and then call
mlflow.register_model. The registry assigns a version number automatically
each time you register under the same model name.
import mlflow
import mlflow.sklearn
from sklearn.linear_model import LogisticRegression
mlflow.set_experiment("shared/my-experiment")
with mlflow.start_run() as run:
model = LogisticRegression()
model.fit(X_train, y_train)
mlflow.sklearn.log_model(model, artifact_path="model")
run_id = run.info.run_id
model_uri = f"runs:/{run_id}/model"
mlflow.register_model(model_uri=model_uri, name="my-classifier")The model appears in the Models section of the MLflow UI under the name you provided.
Load a registered model
You can load any registered model version by name. Use this to run inference or continue training from a saved checkpoint.
Load the latest version:
import mlflow.sklearn
model = mlflow.sklearn.load_model("models:/my-classifier/latest")
predictions = model.predict(X_test)Load a specific version:
model = mlflow.sklearn.load_model("models:/my-classifier/3")View registered models
Open the MLflow UI from the Developer Workspace sidebar to browse all registered models, compare versions, and review their associated runs.
Next steps
- Open the MLflow UI to browse the Model Registry and compare runs.