1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package sagemaker
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/sagemaker/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Starts a hyperparameter tuning job. A hyperparameter tuning job finds the best
15// version of a model by running many training jobs on your dataset using the
16// algorithm you choose and values for hyperparameters within ranges that you
17// specify. It then chooses the hyperparameter values that result in a model that
18// performs the best, as measured by an objective metric that you choose.
19func (c *Client) CreateHyperParameterTuningJob(ctx context.Context, params *CreateHyperParameterTuningJobInput, optFns ...func(*Options)) (*CreateHyperParameterTuningJobOutput, error) {
20	if params == nil {
21		params = &CreateHyperParameterTuningJobInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "CreateHyperParameterTuningJob", params, optFns, addOperationCreateHyperParameterTuningJobMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*CreateHyperParameterTuningJobOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34type CreateHyperParameterTuningJobInput struct {
35
36	// The HyperParameterTuningJobConfig object that describes the tuning job,
37	// including the search strategy, the objective metric used to evaluate training
38	// jobs, ranges of parameters to search, and resource limits for the tuning job.
39	// For more information, see How Hyperparameter Tuning Works
40	// (https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-how-it-works.html).
41	//
42	// This member is required.
43	HyperParameterTuningJobConfig *types.HyperParameterTuningJobConfig
44
45	// The name of the tuning job. This name is the prefix for the names of all
46	// training jobs that this tuning job launches. The name must be unique within the
47	// same AWS account and AWS Region. The name must have 1 to 32 characters. Valid
48	// characters are a-z, A-Z, 0-9, and : + = @ _ % - (hyphen). The name is not case
49	// sensitive.
50	//
51	// This member is required.
52	HyperParameterTuningJobName *string
53
54	// An array of key-value pairs. You can use tags to categorize your AWS resources
55	// in different ways, for example, by purpose, owner, or environment. For more
56	// information, see Tagging AWS Resources
57	// (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html). Tags that you
58	// specify for the tuning job are also added to all training jobs that the tuning
59	// job launches.
60	Tags []types.Tag
61
62	// The HyperParameterTrainingJobDefinition object that describes the training jobs
63	// that this tuning job launches, including static hyperparameters, input data
64	// configuration, output data configuration, resource configuration, and stopping
65	// condition.
66	TrainingJobDefinition *types.HyperParameterTrainingJobDefinition
67
68	// A list of the HyperParameterTrainingJobDefinition objects launched for this
69	// tuning job.
70	TrainingJobDefinitions []types.HyperParameterTrainingJobDefinition
71
72	// Specifies the configuration for starting the hyperparameter tuning job using one
73	// or more previous tuning jobs as a starting point. The results of previous tuning
74	// jobs are used to inform which combinations of hyperparameters to search over in
75	// the new tuning job. All training jobs launched by the new hyperparameter tuning
76	// job are evaluated by using the objective metric. If you specify
77	// IDENTICAL_DATA_AND_ALGORITHM as the WarmStartType value for the warm start
78	// configuration, the training job that performs the best in the new tuning job is
79	// compared to the best training jobs from the parent tuning jobs. From these, the
80	// training job that performs the best as measured by the objective metric is
81	// returned as the overall best training job. All training jobs launched by parent
82	// hyperparameter tuning jobs and the new hyperparameter tuning jobs count against
83	// the limit of training jobs for the tuning job.
84	WarmStartConfig *types.HyperParameterTuningJobWarmStartConfig
85}
86
87type CreateHyperParameterTuningJobOutput struct {
88
89	// The Amazon Resource Name (ARN) of the tuning job. Amazon SageMaker assigns an
90	// ARN to a hyperparameter tuning job when you create it.
91	//
92	// This member is required.
93	HyperParameterTuningJobArn *string
94
95	// Metadata pertaining to the operation's result.
96	ResultMetadata middleware.Metadata
97}
98
99func addOperationCreateHyperParameterTuningJobMiddlewares(stack *middleware.Stack, options Options) (err error) {
100	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateHyperParameterTuningJob{}, middleware.After)
101	if err != nil {
102		return err
103	}
104	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateHyperParameterTuningJob{}, middleware.After)
105	if err != nil {
106		return err
107	}
108	if err = addSetLoggerMiddleware(stack, options); err != nil {
109		return err
110	}
111	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
112		return err
113	}
114	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
115		return err
116	}
117	if err = addResolveEndpointMiddleware(stack, options); err != nil {
118		return err
119	}
120	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
121		return err
122	}
123	if err = addRetryMiddlewares(stack, options); err != nil {
124		return err
125	}
126	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
127		return err
128	}
129	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
130		return err
131	}
132	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
133		return err
134	}
135	if err = addClientUserAgent(stack); err != nil {
136		return err
137	}
138	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
139		return err
140	}
141	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
142		return err
143	}
144	if err = addOpCreateHyperParameterTuningJobValidationMiddleware(stack); err != nil {
145		return err
146	}
147	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateHyperParameterTuningJob(options.Region), middleware.Before); err != nil {
148		return err
149	}
150	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
151		return err
152	}
153	if err = addResponseErrorMiddleware(stack); err != nil {
154		return err
155	}
156	if err = addRequestResponseLogging(stack, options); err != nil {
157		return err
158	}
159	return nil
160}
161
162func newServiceMetadataMiddleware_opCreateHyperParameterTuningJob(region string) *awsmiddleware.RegisterServiceMetadata {
163	return &awsmiddleware.RegisterServiceMetadata{
164		Region:        region,
165		ServiceID:     ServiceID,
166		SigningName:   "sagemaker",
167		OperationName: "CreateHyperParameterTuningJob",
168	}
169}
170