Create a Model Group
A Model Group contains different versions of a model. You can create a Model Group that tracks all of the models that you train to solve a particular problem. Create a Model Group by using either the AWS SDK for Python (Boto3) or the Amazon SageMaker Studio console.
Create a Model Group (Boto3)
Important
Custom IAM policies that allow Amazon SageMaker Studio or Amazon SageMaker Studio Classic to create Amazon SageMaker resources must also grant permissions to add tags to those resources. The permission to add tags to resources is required because Studio and Studio Classic automatically tag any resources they create. If an IAM policy allows Studio and Studio Classic to create resources but does not allow tagging, "AccessDenied" errors can occur when trying to create resources. For more information, see Provide permissions for tagging SageMaker AI resources.
AWS managed policies for Amazon SageMaker AI that give permissions to create SageMaker resources already include permissions to add tags while creating those resources.
To create a Model Group by using Boto3, call the
create_model_package_group
API operation and specify a name and
description as parameters. The following example shows how to create a Model
Group. The response from the create_model_package_group
call is the
Amazon Resource Name (ARN) of the new Model Group.
First, import the required packages and set up the SageMaker AI Boto3 client.
import time import os from sagemaker import get_execution_role, session import boto3 region = boto3.Session().region_name role = get_execution_role() sm_client = boto3.client('sagemaker', region_name=region)
Now create the Model Group.
import time model_package_group_name = "scikit-iris-detector-" + str(round(time.time())) model_package_group_input_dict = { "ModelPackageGroupName" : model_package_group_name, "ModelPackageGroupDescription" : "Sample model package group" } create_model_package_group_response = sm_client.create_model_package_group(**model_package_group_input_dict) print('ModelPackageGroup Arn : {}'.format(create_model_package_group_response['ModelPackageGroupArn']))
Create a Model Group (Studio or Studio Classic)
To create a Model Group in the Amazon SageMaker Studio console, complete the following steps based on whether you use Studio or Studio Classic.