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.

已提问 10 个月前538 查看次数
1 回答
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
已回答 9 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容