How to fetch a model and make predictions from the Model Registry

0

Hello! I have a model in the Sagemaker Studio Model Registry. Is there a way to do something like the following?

sm = boto3.client('sagemaker')
model = sm.fetch_model('model_group_name')
preds = model.predict(X)

I'm used to using MLFlow, where you can do

import mlflow.sklearn

sk_model = mlflow.sklearn.load_model("runs:/96771d893a5e46159d9f3b49bf9013e2/sk_models")

# use Pandas DataFrame to make predictions
pandas_df = ...
predictions = sk_model.predict(pandas_df)

I can't find an equivalent of the sm.fetch_model() function. I'm looking for something along the lines of a MLFlow equivalent. I want to do some predictions without having a model deployed.

  • A model registry in SageMaker is a catalog of models. If you'd like to predict without deploying the model, I believe the way would be to download the model from the model registry's S3 location, load the model and then predict.

demandé il y a 10 mois540 vues
1 réponse
0

SageMaker Model Registry can be used to catalog and manage different model versions. model_group_name can't be used directly from Sagemaker Model Registry. First you need to deploy the model. After deploying the model, Endpoint would be created. Then you can directly invoke the Endpoint API.

Generally at first Model You need to to create a Model group[1] << Register a Model Version using Sagemaker Model registry [2] << Update the Approval Status of a Model to approved[3] << Deploy the Model for registry[4] << Invoke the Endpoint API.

Kindly go through the below example of deploying the model and then invoking it via Endpoint API https://github.com/aws/amazon-sagemaker-examples/blob/main/serverless-inference/serverless-model-registry.ipynb

[1] https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry-model-group.html [2] https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry-version.html [3] https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry-approve.html [4] https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry-deploy.html

Yash_A
répondu il y a 10 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions