SageMaker / Client / create_auto_ml_job
create_auto_ml_job#
- SageMaker.Client.create_auto_ml_job(**kwargs)#
Creates an Autopilot job also referred to as Autopilot experiment or AutoML job.
An AutoML job in SageMaker AI is a fully automated process that allows you to build machine learning models with minimal effort and machine learning expertise. When initiating an AutoML job, you provide your data and optionally specify parameters tailored to your use case. SageMaker AI then automates the entire model development lifecycle, including data preprocessing, model training, tuning, and evaluation. AutoML jobs are designed to simplify and accelerate the model building process by automating various tasks and exploring different combinations of machine learning algorithms, data preprocessing techniques, and hyperparameter values. The output of an AutoML job comprises one or more trained models ready for deployment and inference. Additionally, SageMaker AI AutoML jobs generate a candidate model leaderboard, allowing you to select the best-performing model for deployment.
For more information about AutoML jobs, see https://docs.aws.amazon.com/sagemaker/latest/dg/autopilot-automate-model-development.html in the SageMaker AI developer guide.
Note
We recommend using the new versions CreateAutoMLJobV2 and DescribeAutoMLJobV2, which offer backward compatibility.
CreateAutoMLJobV2
can manage tabular problem types identical to those of its previous versionCreateAutoMLJob
, as well as time-series forecasting, non-tabular problem types such as image or text classification, and text generation (LLMs fine-tuning).Find guidelines about how to migrate a
CreateAutoMLJob
toCreateAutoMLJobV2
in Migrate a CreateAutoMLJob to CreateAutoMLJobV2.You can find the best-performing model after you run an AutoML job by calling DescribeAutoMLJobV2 (recommended) or DescribeAutoMLJob.
See also: AWS API Documentation
Request Syntax
response = client.create_auto_ml_job( AutoMLJobName='string', InputDataConfig=[ { 'DataSource': { 'S3DataSource': { 'S3DataType': 'ManifestFile'|'S3Prefix'|'AugmentedManifestFile', 'S3Uri': 'string' } }, 'CompressionType': 'None'|'Gzip', 'TargetAttributeName': 'string', 'ContentType': 'string', 'ChannelType': 'training'|'validation', 'SampleWeightAttributeName': 'string' }, ], OutputDataConfig={ 'KmsKeyId': 'string', 'S3OutputPath': 'string' }, ProblemType='BinaryClassification'|'MulticlassClassification'|'Regression', AutoMLJobObjective={ 'MetricName': 'Accuracy'|'MSE'|'F1'|'F1macro'|'AUC'|'RMSE'|'BalancedAccuracy'|'R2'|'Recall'|'RecallMacro'|'Precision'|'PrecisionMacro'|'MAE'|'MAPE'|'MASE'|'WAPE'|'AverageWeightedQuantileLoss' }, AutoMLJobConfig={ 'CompletionCriteria': { 'MaxCandidates': 123, 'MaxRuntimePerTrainingJobInSeconds': 123, 'MaxAutoMLJobRuntimeInSeconds': 123 }, 'SecurityConfig': { 'VolumeKmsKeyId': 'string', 'EnableInterContainerTrafficEncryption': True|False, 'VpcConfig': { 'SecurityGroupIds': [ 'string', ], 'Subnets': [ 'string', ] } }, 'CandidateGenerationConfig': { 'FeatureSpecificationS3Uri': 'string', 'AlgorithmsConfig': [ { 'AutoMLAlgorithms': [ 'xgboost'|'linear-learner'|'mlp'|'lightgbm'|'catboost'|'randomforest'|'extra-trees'|'nn-torch'|'fastai'|'cnn-qr'|'deepar'|'prophet'|'npts'|'arima'|'ets', ] }, ] }, 'DataSplitConfig': { 'ValidationFraction': ... }, 'Mode': 'AUTO'|'ENSEMBLING'|'HYPERPARAMETER_TUNING' }, RoleArn='string', GenerateCandidateDefinitionsOnly=True|False, Tags=[ { 'Key': 'string', 'Value': 'string' }, ], ModelDeployConfig={ 'AutoGenerateEndpointName': True|False, 'EndpointName': 'string' } )
- Parameters:
AutoMLJobName (string) –
[REQUIRED]
Identifies an Autopilot job. The name must be unique to your account and is case insensitive.
InputDataConfig (list) –
[REQUIRED]
An array of channel objects that describes the input data and its location. Each channel is a named input source. Similar to
InputDataConfig
supported by HyperParameterTrainingJobDefinition. Format(s) supported: CSV, Parquet. A minimum of 500 rows is required for the training dataset. There is not a minimum number of rows required for the validation dataset.(dict) –
A channel is a named input source that training algorithms can consume. The validation dataset size is limited to less than 2 GB. The training dataset size must be less than 100 GB. For more information, see Channel.
Note
A validation dataset must contain the same headers as the training dataset.
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 AI uses all objects that match the specified key name prefix for model training. TheS3Prefix
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 AI to use for model training. AManifestFile
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 callingCreateAutoMLJobV2
). Here is a minimal, single-record example of anAugmentedManifestFile
:{"source-ref": "s3://DOC-EXAMPLE-BUCKET/DOC-EXAMPLE-FOLDER/cats/cat.jpg",
"label-metadata": {"class-name": "cat"
} For more information onAugmentedManifestFile
, 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.
CompressionType (string) –
You can use
Gzip
orNone
. The default value isNone
.TargetAttributeName (string) – [REQUIRED]
The name of the target variable in supervised learning, usually represented by ‘y’.
ContentType (string) –
The content type of the data from the input source. You can use
text/csv;header=present
orx-application/vnd.amazon+parquet
. The default value istext/csv;header=present
.ChannelType (string) –
The channel type (optional) is an
enum
string. The default value istraining
. Channels for training and validation must share the sameContentType
andTargetAttributeName
. For information on specifying training and validation channel types, see How to specify training and validation datasets.SampleWeightAttributeName (string) –
If specified, this column name indicates which column of the dataset should be treated as sample weights for use by the objective metric during the training, evaluation, and the selection of the best model. This column is not considered as a predictive feature. For more information on Autopilot metrics, see Metrics and validation.
Sample weights should be numeric, non-negative, with larger values indicating which rows are more important than others. Data points that have invalid or no weight value are excluded.
Support for sample weights is available in Ensembling mode only.
OutputDataConfig (dict) –
[REQUIRED]
Provides information about encryption and the Amazon S3 output path needed to store artifacts from an AutoML job. Format(s) supported: CSV.
KmsKeyId (string) –
The Key Management Service encryption key ID.
S3OutputPath (string) – [REQUIRED]
The Amazon S3 output path. Must be 512 characters or less.
ProblemType (string) – Defines the type of supervised learning problem available for the candidates. For more information, see SageMaker Autopilot problem types.
AutoMLJobObjective (dict) –
Specifies a metric to minimize or maximize as the objective of a job. If not specified, the default objective metric depends on the problem type. See AutoMLJobObjective for the default values.
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.
The list of available metrics supported by Autopilot and the default metric applied when you do not specify a metric name explicitly depend on the problem type.
For tabular problem types:
List of available metrics:
Regression:
MAE
,MSE
,R2
,RMSE
Binary classification:
Accuracy
,AUC
,BalancedAccuracy
,F1
,Precision
,Recall
Multiclass classification:
Accuracy
,BalancedAccuracy
,F1macro
,PrecisionMacro
,RecallMacro
For a description of each metric, see Autopilot metrics for classification and regression.
Default objective metrics:
Regression:
MSE
.Binary classification:
F1
.Multiclass classification:
Accuracy
.
For image or text classification problem types:
List of available metrics:
Accuracy
For a description of each metric, see Autopilot metrics for text and image classification.Default objective metrics:
Accuracy
For time-series forecasting problem types:
List of available metrics:
RMSE
,wQL
,Average wQL
,MASE
,MAPE
,WAPE
For a description of each metric, see Autopilot metrics for time-series forecasting.Default objective metrics:
AverageWeightedQuantileLoss
For text generation problem types (LLMs fine-tuning): Fine-tuning language models in Autopilot does not require setting the
AutoMLJobObjective
field. Autopilot fine-tunes LLMs without requiring multiple candidates to be trained and evaluated. Instead, using your dataset, Autopilot directly fine-tunes your target model to enhance a default objective metric, the cross-entropy loss. After fine-tuning a language model, you can evaluate the quality of its generated text using different metrics. For a list of the available metrics, see Metrics for fine-tuning LLMs in Autopilot.
AutoMLJobConfig (dict) –
A collection of settings used to configure an AutoML job.
CompletionCriteria (dict) –
How long an AutoML 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 text and image classification, time-series forecasting, as well as text generation (LLMs fine-tuning) problem types, the supported value is 1. For tabular problem types, the maximum value is 750.
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 job V2s (jobs created by calling
CreateAutoMLJobV2
), this field controls the runtime of the job candidate.For TextGenerationJobConfig problem types, the maximum time defaults to 72 hours (259200 seconds).
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.
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 theSubnets
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) –
CandidateGenerationConfig (dict) –
The configuration for generating a candidate for an AutoML job (optional).
FeatureSpecificationS3Uri (string) –
A URL to the Amazon S3 data source containing selected features from the input data source to run an Autopilot job. You can input
FeatureAttributeNames
(optional) in JSON format as shown below:{ "FeatureAttributeNames":["col1", "col2", ...] }
.You can also specify the data type of the feature (optional) in the format shown below:
{ "FeatureDataTypes":{"col1":"numeric", "col2":"categorical" ... } }
Note
These column keys may not include the target column.
In ensembling mode, Autopilot only supports the following data types:
numeric
,categorical
,text
, anddatetime
. In HPO mode, Autopilot can supportnumeric
,categorical
,text
,datetime
, andsequence
.If only
FeatureDataTypes
is provided, the column keys (col1
,col2
,..) should be a subset of the column names in the input data.If both
FeatureDataTypes
andFeatureAttributeNames
are provided, then the column keys should be a subset of the column names provided inFeatureAttributeNames
.The key name
FeatureAttributeNames
is fixed. The values listed in["col1", "col2", ...]
are case sensitive and should be a list of strings containing unique values that are a subset of the column names in the input data. The list of columns provided must not include the target column.AlgorithmsConfig (list) –
Stores the configuration information for the selection of algorithms trained on tabular data.
The list of available algorithms to choose from depends on the training mode set in TabularJobConfig.Mode.
AlgorithmsConfig
should not be set if the training mode is set onAUTO
.When
AlgorithmsConfig
is provided, oneAutoMLAlgorithms
attribute must be set and one only. If the list of algorithms provided as values forAutoMLAlgorithms
is empty,CandidateGenerationConfig
uses the full set of algorithms for the given training mode.When
AlgorithmsConfig
is not provided,CandidateGenerationConfig
uses the full set of algorithms for the given training mode.
For the list of all algorithms per problem type and training mode, see AutoMLAlgorithmConfig.
For more information on each algorithm, see the Algorithm support section in Autopilot developer guide.
(dict) –
The selection of algorithms trained on your dataset to generate the model candidates for an Autopilot job.
AutoMLAlgorithms (list) – [REQUIRED]
The selection of algorithms trained on your dataset to generate the model candidates for an Autopilot job.
For the tabular problem type
TabularJobConfig
:
Note
Selected algorithms must belong to the list corresponding to the training mode set in AutoMLJobConfig.Mode (
ENSEMBLING
orHYPERPARAMETER_TUNING
). Choose a minimum of 1 algorithm.In
ENSEMBLING
mode:”catboost”
”extra-trees”
”fastai”
”lightgbm”
”linear-learner”
”nn-torch”
”randomforest”
”xgboost”
In
HYPERPARAMETER_TUNING
mode:”linear-learner”
”mlp”
”xgboost”
For the time-series forecasting problem type
TimeSeriesForecastingJobConfig
:Choose your algorithms from this list.
”cnn-qr”
”deepar”
”prophet”
”arima”
”npts”
”ets”
(string) –
DataSplitConfig (dict) –
The configuration for splitting the input training dataset.
Type: AutoMLDataSplitConfig
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.
Mode (string) –
The method that Autopilot uses to train the data. You can either specify the mode manually or let Autopilot choose for you based on the dataset size by selecting
AUTO
. InAUTO
mode, Autopilot choosesENSEMBLING
for datasets smaller than 100 MB, andHYPERPARAMETER_TUNING
for larger ones.The
ENSEMBLING
mode uses a multi-stack ensemble model to predict classification and regression tasks directly from your dataset. This machine learning mode combines several base models to produce an optimal predictive model. It then uses a stacking ensemble method to combine predictions from contributing members. A multi-stack ensemble model can provide better performance over a single model by combining the predictive capabilities of multiple models. See Autopilot algorithm support for a list of algorithms supported byENSEMBLING
mode.The
HYPERPARAMETER_TUNING
(HPO) mode uses the best hyperparameters to train the best version of a model. HPO automatically selects an algorithm for the type of problem you want to solve. Then HPO finds the best hyperparameters according to your objective metric. See Autopilot algorithm support for a list of algorithms supported byHYPERPARAMETER_TUNING
mode.
RoleArn (string) –
[REQUIRED]
The ARN of the role that is used to access the data.
GenerateCandidateDefinitionsOnly (boolean) – Generates possible candidates without training the models. A candidate is a combination of data preprocessors, algorithms, and algorithm parameter settings.
Tags (list) –
An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, 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.
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 toFalse
otherwise. The default value isFalse
.Note
If you set
AutoGenerateEndpointName
toTrue
, do not specify theEndpointName
; 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 setAutoGenerateEndpointName
toFalse
; otherwise a 400 error is thrown.
- Return type:
dict
- Returns:
Response Syntax
{ 'AutoMLJobArn': 'string' }
Response Structure
(dict) –
AutoMLJobArn (string) –
The unique ARN assigned to the AutoML job when it is created.
Exceptions