SageMaker / Client / create_auto_ml_job_v2

create_auto_ml_job_v2#

SageMaker.Client.create_auto_ml_job_v2(**kwargs)#

Creates an Amazon SageMaker AutoML job that uses non-tabular data such as images or text for Computer Vision or Natural Language Processing problems.

Find the resulting model after you run an AutoML job V2 by calling DescribeAutoMLJobV2.

To create an AutoMLJob using tabular data, see CreateAutoMLJob.

Note

This API action is callable through SageMaker Canvas only. Calling it directly from the CLI or an SDK results in an error.

See also: AWS API Documentation

Request Syntax

response = client.create_auto_ml_job_v2(
    AutoMLJobName='string',
    AutoMLJobInputDataConfig=[
        {
            'ChannelType': 'training'|'validation',
            'ContentType': 'string',
            'CompressionType': 'None'|'Gzip',
            'DataSource': {
                'S3DataSource': {
                    'S3DataType': 'ManifestFile'|'S3Prefix'|'AugmentedManifestFile',
                    'S3Uri': 'string'
                }
            }
        },
    ],
    OutputDataConfig={
        'KmsKeyId': 'string',
        'S3OutputPath': 'string'
    },
    AutoMLProblemTypeConfig={
        'ImageClassificationJobConfig': {
            'CompletionCriteria': {
                'MaxCandidates': 123,
                'MaxRuntimePerTrainingJobInSeconds': 123,
                'MaxAutoMLJobRuntimeInSeconds': 123
            }
        },
        'TextClassificationJobConfig': {
            'CompletionCriteria': {
                'MaxCandidates': 123,
                'MaxRuntimePerTrainingJobInSeconds': 123,
                'MaxAutoMLJobRuntimeInSeconds': 123
            },
            'ContentColumn': 'string',
            'TargetLabelColumn': 'string'
        }
    },
    RoleArn='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    SecurityConfig={
        'VolumeKmsKeyId': 'string',
        'EnableInterContainerTrafficEncryption': True|False,
        'VpcConfig': {
            'SecurityGroupIds': [
                'string',
            ],
            'Subnets': [
                'string',
            ]
        }
    },
    AutoMLJobObjective={
        'MetricName': 'Accuracy'|'MSE'|'F1'|'F1macro'|'AUC'|'RMSE'|'MAE'|'R2'|'BalancedAccuracy'|'Precision'|'PrecisionMacro'|'Recall'|'RecallMacro'
    },
    ModelDeployConfig={
        'AutoGenerateEndpointName': True|False,
        'EndpointName': 'string'
    },
    DataSplitConfig={
        'ValidationFraction': ...
    }
)
Parameters:
  • AutoMLJobName (string) –

    [REQUIRED]

    Identifies an Autopilot job. The name must be unique to your account and is case insensitive.

  • AutoMLJobInputDataConfig (list) –

    [REQUIRED]

    An array of channel objects describing the input data and their location. Each channel is a named input source. Similar to InputDataConfig supported by CreateAutoMLJob. The supported formats depend on the problem type:

    • ImageClassification: S3Prefix, ManifestFile, AugmentedManifestFile

    • TextClassification: S3Prefix

    • (dict) –

      A channel is a named input source that training algorithms can consume. This channel is used for the non tabular training data of an AutoML job using the V2 API. For tabular training data, see AutoMLChannel. For more information, see Channel.

      • ChannelType (string) –

        The type of channel. Defines whether the data are used for training or validation. The default value is training. Channels for training and validation must share the same ContentType

      • ContentType (string) –

        The content type of the data from the input source. The following are the allowed content types for different problems:

        • ImageClassification: image/png, image/jpeg, image/*

        • TextClassification: text/csv;header=present

      • CompressionType (string) –

        The allowed compression types depend on the input format. We allow the compression type Gzip for S3Prefix inputs only. For all other inputs, the compression type should be None. If no compression type is provided, we default to None.

      • DataSource (dict) –

        The data source for an AutoML channel.

        • S3DataSource (dict) – [REQUIRED]

          The Amazon S3 location of the input data.

          • S3DataType (string) – [REQUIRED]

            The data type.

            • If you choose S3Prefix, S3Uri identifies a key name prefix. SageMaker uses all objects that match the specified key name prefix for model training. The S3Prefix should have the following format: s3://DOC-EXAMPLE-BUCKET/DOC-EXAMPLE-FOLDER-OR-FILE

            • If you choose ManifestFile, S3Uri identifies an object that is a manifest file containing a list of object keys that you want SageMaker to use for model training. A ManifestFile should have the format shown below: [ {"prefix": "s3://DOC-EXAMPLE-BUCKET/DOC-EXAMPLE-FOLDER/DOC-EXAMPLE-PREFIX/"}, "DOC-EXAMPLE-RELATIVE-PATH/DOC-EXAMPLE-FOLDER/DATA-1", "DOC-EXAMPLE-RELATIVE-PATH/DOC-EXAMPLE-FOLDER/DATA-2", ... "DOC-EXAMPLE-RELATIVE-PATH/DOC-EXAMPLE-FOLDER/DATA-N" ]

            • If you choose AugmentedManifestFile, S3Uri identifies an object that is an augmented manifest file in JSON lines format. This file contains the data you want to use for model training. AugmentedManifestFile is available for V2 API jobs only (for example, for jobs created by calling CreateAutoMLJobV2). Here is a minimal, single-record example of an AugmentedManifestFile: {"source-ref": "s3://DOC-EXAMPLE-BUCKET/DOC-EXAMPLE-FOLDER/cats/cat.jpg", "label-metadata": {"class-name": "cat" } For more information on AugmentedManifestFile, see Provide Dataset Metadata to Training Jobs with an Augmented Manifest File.

          • S3Uri (string) – [REQUIRED]

            The URL to the Amazon S3 data source. The Uri refers to the Amazon S3 prefix or ManifestFile depending on the data type.

  • OutputDataConfig (dict) –

    [REQUIRED]

    Provides information about encryption and the Amazon S3 output path needed to store artifacts from an AutoML job.

    • KmsKeyId (string) –

      The Key Management Service (KMS) encryption key ID.

    • S3OutputPath (string) – [REQUIRED]

      The Amazon S3 output path. Must be 128 characters or less.

  • AutoMLProblemTypeConfig (dict) –

    [REQUIRED]

    Defines the configuration settings of one of the supported problem types.

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: ImageClassificationJobConfig, TextClassificationJobConfig.

    • ImageClassificationJobConfig (dict) –

      Settings used to configure an AutoML job using the V2 API for the image classification problem type.

      • CompletionCriteria (dict) –

        How long a job is allowed to run, or how many candidates a job is allowed to generate.

        • MaxCandidates (integer) –

          The maximum number of times a training job is allowed to run.

          For V2 jobs (jobs created by calling CreateAutoMLJobV2), the supported value is 1.

        • MaxRuntimePerTrainingJobInSeconds (integer) –

          The maximum time, in seconds, that each training job executed inside hyperparameter tuning is allowed to run as part of a hyperparameter tuning job. For more information, see the StoppingCondition used by the CreateHyperParameterTuningJob action.

          For V2 jobs (jobs created by calling CreateAutoMLJobV2), this field controls the runtime of the job candidate.

        • MaxAutoMLJobRuntimeInSeconds (integer) –

          The maximum runtime, in seconds, an AutoML job has to complete.

          If an AutoML job exceeds the maximum runtime, the job is stopped automatically and its processing is ended gracefully. The AutoML job identifies the best model whose training was completed and marks it as the best-performing model. Any unfinished steps of the job, such as automatic one-click Autopilot model deployment, are not completed.

    • TextClassificationJobConfig (dict) –

      Settings used to configure an AutoML job using the V2 API for the text classification problem type.

      • CompletionCriteria (dict) –

        How long a job is allowed to run, or how many candidates a job is allowed to generate.

        • MaxCandidates (integer) –

          The maximum number of times a training job is allowed to run.

          For V2 jobs (jobs created by calling CreateAutoMLJobV2), the supported value is 1.

        • MaxRuntimePerTrainingJobInSeconds (integer) –

          The maximum time, in seconds, that each training job executed inside hyperparameter tuning is allowed to run as part of a hyperparameter tuning job. For more information, see the StoppingCondition used by the CreateHyperParameterTuningJob action.

          For V2 jobs (jobs created by calling CreateAutoMLJobV2), this field controls the runtime of the job candidate.

        • MaxAutoMLJobRuntimeInSeconds (integer) –

          The maximum runtime, in seconds, an AutoML job has to complete.

          If an AutoML job exceeds the maximum runtime, the job is stopped automatically and its processing is ended gracefully. The AutoML job identifies the best model whose training was completed and marks it as the best-performing model. Any unfinished steps of the job, such as automatic one-click Autopilot model deployment, are not completed.

      • ContentColumn (string) –

        The name of the column used to provide the sentences to be classified. It should not be the same as the target column.

      • TargetLabelColumn (string) –

        The name of the column used to provide the class labels. It should not be same as the content column.

  • RoleArn (string) –

    [REQUIRED]

    The ARN of the role that is used to access the data.

  • Tags (list) –

    An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, such as by purpose, owner, or environment. For more information, see Tagging Amazon Web ServicesResources. Tag keys must be unique per resource.

    • (dict) –

      A tag object that consists of a key and an optional value, used to manage metadata for SageMaker Amazon Web Services resources.

      You can add tags to notebook instances, training jobs, hyperparameter tuning jobs, batch transform jobs, models, labeling jobs, work teams, endpoint configurations, and endpoints. For more information on adding tags to SageMaker resources, see AddTags.

      For more information on adding metadata to your Amazon Web Services resources with tagging, see Tagging Amazon Web Services resources. For advice on best practices for managing Amazon Web Services resources with tagging, see Tagging Best Practices: Implement an Effective Amazon Web Services Resource Tagging Strategy.

      • Key (string) – [REQUIRED]

        The tag key. Tag keys must be unique per resource.

      • Value (string) – [REQUIRED]

        The tag value.

  • SecurityConfig (dict) –

    The security configuration for traffic encryption or Amazon VPC settings.

    • VolumeKmsKeyId (string) –

      The key used to encrypt stored data.

    • EnableInterContainerTrafficEncryption (boolean) –

      Whether to use traffic encryption between the container layers.

    • VpcConfig (dict) –

      The VPC configuration.

      • SecurityGroupIds (list) – [REQUIRED]

        The VPC security group IDs, in the form sg-xxxxxxxx. Specify the security groups for the VPC that is specified in the Subnets field.

        • (string) –

      • Subnets (list) – [REQUIRED]

        The ID of the subnets in the VPC to which you want to connect your training job or model. For information about the availability of specific instance types, see Supported Instance Types and Availability Zones.

        • (string) –

  • AutoMLJobObjective (dict) –

    Specifies a metric to minimize or maximize as the objective of a job. For CreateAutoMLJobV2, only Accuracy is supported.

    • MetricName (string) – [REQUIRED]

      The name of the objective metric used to measure the predictive quality of a machine learning system. During training, the model’s parameters are updated iteratively to optimize its performance based on the feedback provided by the objective metric when evaluating the model on the validation dataset.

      For the list of all available metrics supported by Autopilot, see Autopilot metrics.

      If you do not specify a metric explicitly, the default behavior is to automatically use:

      • MSE: for regression.

      • F1: for binary classification

      • Accuracy: for multiclass classification.

  • ModelDeployConfig (dict) –

    Specifies how to generate the endpoint name for an automatic one-click Autopilot model deployment.

    • AutoGenerateEndpointName (boolean) –

      Set to True to automatically generate an endpoint name for a one-click Autopilot model deployment; set to False otherwise. The default value is False.

      Note

      If you set AutoGenerateEndpointName to True, do not specify the EndpointName; otherwise a 400 error is thrown.

    • EndpointName (string) –

      Specifies the endpoint name to use for a one-click Autopilot model deployment if the endpoint name is not generated automatically.

      Note

      Specify the EndpointName if and only if you set AutoGenerateEndpointName to False; otherwise a 400 error is thrown.

  • DataSplitConfig (dict) –

    This structure specifies how to split the data into train and validation datasets.

    If you are using the V1 API (for example CreateAutoMLJob) or the V2 API for Natural Language Processing problems (for example CreateAutoMLJobV2 with a TextClassificationJobConfig problem type), the validation and training datasets must contain the same headers. Also, for V1 API jobs, the validation dataset must be less than 2 GB in size.

    • ValidationFraction (float) –

      The validation fraction (optional) is a float that specifies the portion of the training dataset to be used for validation. The default value is 0.2, and values must be greater than 0 and less than 1. We recommend setting this value to be less than 0.5.

Return type:

dict

Returns:

Response Syntax

{
    'AutoMLJobArn': 'string'
}

Response Structure

  • (dict) –

    • AutoMLJobArn (string) –

      The unique ARN assigned to the AutoMLJob when it is created.

Exceptions

  • SageMaker.Client.exceptions.ResourceInUse

  • SageMaker.Client.exceptions.ResourceLimitExceeded