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 個月前檢視次數 540 次
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
已回答 10 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南