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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠