Reputation: 657
I'm stuck with the MLFlow model registry. Does anyone know how to load a model using the object "mlflow.tracking.client.MlflowClient"?
I would like to do a predict after with that. I'm sure I'm wrong somewhere because I've already done that in the past. I'm not able to find it in the doc, in the web.
Upvotes: 0
Views: 2259
Reputation: 396
You'll have to make use of mlflow.<model_flavor>.load_model()
to load a given model from the Model Registry. For example:
import mlflow.pyfunc
model = mlflow.pyfunc.load_model(
model_uri="models:/<model_name>/<model_version>"
)
model.predict(...)
With mlflow.tracking.client.MlflowClient
you can retrieve metadata about a model from the model registry, but for retrieving the actual model you will need to use mlflow.<model_flavor>.load_model
. For example, you could use the MlflowClient to get the download URI for a given model, and then use mlflow.<flavor>.load_model
to retrieve that model.
model_uri = client.get_model_version_download_uri("<model_name>", <version>)
model = mlflow.pyfunc.load_model(model_uri)
model.predict(...)
Upvotes: 2