Notebooks
A
Amazon Web Services
Sm Model Governance Model Card With Model Package

Sm Model Governance Model Card With Model Package

data-scienceinferenceamazon-sagemaker-examplessm-model_governance_model_card_with_model_packagereinforcement-learningmachine-learningawsresponsible_aiexamplesdeep-learningsagemakerjupyter-notebooktrainingmlops

Amazon SageMaker Model Governance - Model Cards Model Registry integration


This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook.

This us-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable


This notebook walks you through the new feature of Amazon SageMaker Model Cards Model Registry Integration. To learn about the existing features and for more information on model cards, see Model Cards in the Amazon SageMaker Developer Guide.

Amazon SageMaker Model Cards give you the ability to create a centralized, customizable fact-sheet to document critical details about your machine learning (ML) models. Use model cards to keep a record of model information, such as intended uses, risk ratings, training details, evaluation metrics, and more for streamlined governance and reporting.

In this example, you will create a model package along with a model card to document model package details along the way. Learn how to create a model card by associating model package using the Amazon SageMaker Python SDK.


Contents

  1. Setup
  2. Create a model package
  3. Create Model Card
  4. Cleanup

Setup

To begin, you must specify the following information:

  • The IAM role ARN used to give SageMaker training and hosting access to your data. The following example uses the SageMaker execution role.
  • The SageMaker session used to manage interactions with Amazon SageMaker Model Card API methods.
  • The S3 URI (bucket and prefix) where you want to store training artifacts, models, and any exported model card PDFs. This S3 bucket should be in the same Region as your Notebook Instance, training, and hosting configurations. The following example uses the default SageMaker S3 bucket and creates a default SageMaker S3 bucket if one does not already exist.
  • The S3 session used to manage interactions with Amazon S3 storage.
[ ]
[ ]

Next, import the necessary Python libraries.

[ ]

Prepare a Model (Model package)

The following code creates an example model package trained on a synthetic dataset. The target variable (0 or 1) is the second variable in the tuple.

1. Prepare the training data

The code will upload example data to your S3 bucket.

[ ]

2. Create a training job

Train a binary classification model with the training data from the previous step.

[ ]

2. Create a model package

[ ]

Create Model Card

Document your model package details in an Amazon SageMaker Model Card using the SageMaker Python SDK.

1. Collect model package details

Automatically collect basic model package information like model package ARN, model package group name, model package approval status, and model package's inference specification information.

[ ]

2. Initialize a model card

Initialize a model card with the model package details collected in the previous step. When associating model package to a model card, model card will try to auto discover information like training job details and evaluation job details only if there are information like model artifacts and model metrics available in model package. Additionally, it will also try to carry over some additional information like business details to this model card from the previously created the most recent model card that is associated with this particular model package group.

[ ]

Information inheritance

Additionally, new model card will also try to carry over some additional information like business details, intended uses, additional information to this model card from the previously created the most recent model card that is associated with this particular model package group. In this example, check out the intended uses that is automatically carried over from the previous model card.

[ ]

Cleanup (Optional)

Delete the following resources:

  1. The model card
  2. The model package
  3. The model package group
[ ]

Notebook CI Test Results

This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.

This us-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This us-east-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This us-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ca-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This sa-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-west-3 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-north-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-southeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-southeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-northeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-northeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-south-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable