createSolution method

Future<CreateSolutionResponse> createSolution({
  1. required String datasetGroupArn,
  2. required String name,
  3. String? eventType,
  4. bool? performAutoML,
  5. bool? performAutoTraining,
  6. bool? performHPO,
  7. bool? performIncrementalUpdate,
  8. String? recipeArn,
  9. SolutionConfig? solutionConfig,
  10. List<Tag>? tags,
})
Creates the configuration for training a model (creating a solution version). This configuration includes the recipe to use for model training and optional training configuration, such as columns to use in training and feature transformation parameters. For more information about configuring a solution, see Creating and configuring a solution.

By default, new solutions use automatic training to create solution versions every 7 days. You can change the training frequency. Automatic solution version creation starts within one hour after the solution is ACTIVE. If you manually create a solution version within the hour, the solution skips the first automatic training. For more information, see Configuring automatic training.

To turn off automatic training, set performAutoTraining to false. If you turn off automatic training, you must manually create a solution version by calling the CreateSolutionVersion operation.

After training starts, you can get the solution version's Amazon Resource Name (ARN) with the ListSolutionVersions API operation. To get its status, use the DescribeSolutionVersion.

After training completes you can evaluate model accuracy by calling GetSolutionMetrics. When you are satisfied with the solution version, you deploy it using CreateCampaign. The campaign provides recommendations to a client through the GetRecommendations API. Status

A solution can be in one of the following states:

  • CREATE PENDING > CREATE IN_PROGRESS > ACTIVE -or- CREATE FAILED
  • DELETE PENDING > DELETE IN_PROGRESS
To get the status of the solution, call DescribeSolution. If you use manual training, the status must be ACTIVE before you call CreateSolutionVersion.

Related APIs

May throw InvalidInputException. May throw LimitExceededException. May throw ResourceAlreadyExistsException. May throw ResourceInUseException. May throw ResourceNotFoundException. May throw TooManyTagsException.

Parameter datasetGroupArn : The Amazon Resource Name (ARN) of the dataset group that provides the training data.

Parameter name : The name for the solution.

Parameter eventType : When your have multiple event types (using an EVENT_TYPE schema field), this parameter specifies which event type (for example, 'click' or 'like') is used for training the model.

If you do not provide an eventType, Amazon Personalize will use all interactions for training with equal weight regardless of type.

Parameter performAutoML : Whether to perform automated machine learning (AutoML). The default is false. For this case, you must specify recipeArn.

When set to true, Amazon Personalize analyzes your training data and selects the optimal USER_PERSONALIZATION recipe and hyperparameters. In this case, you must omit recipeArn. Amazon Personalize determines the optimal recipe by running tests with different values for the hyperparameters. AutoML lengthens the training process as compared to selecting a specific recipe.

Parameter performAutoTraining : Whether the solution uses automatic training to create new solution versions (trained models). The default is True and the solution automatically creates new solution versions every 7 days. You can change the training frequency by specifying a schedulingExpression in the AutoTrainingConfig as part of solution configuration. For more information about automatic training, see Configuring automatic training.

Automatic solution version creation starts within one hour after the solution is ACTIVE. If you manually create a solution version within the hour, the solution skips the first automatic training.

After training starts, you can get the solution version's Amazon Resource Name (ARN) with the ListSolutionVersions API operation. To get its status, use the DescribeSolutionVersion.

Parameter performHPO : Whether to perform hyperparameter optimization (HPO) on the specified or selected recipe. The default is false.

When performing AutoML, this parameter is always true and you should not set it to false.

Parameter performIncrementalUpdate : Whether to perform incremental training updates on your model. When enabled, this allows the model to learn from new data more frequently without requiring full retraining, which enables near real-time personalization. This parameter is supported only for solutions that use the semantic-similarity recipe.

Parameter recipeArn : The Amazon Resource Name (ARN) of the recipe to use for model training. This is required when performAutoML is false. For information about different Amazon Personalize recipes and their ARNs, see Choosing a recipe.

Parameter solutionConfig : The configuration properties for the solution. When performAutoML is set to true, Amazon Personalize only evaluates the autoMLConfig section of the solution configuration.

Parameter tags : A list of tags to apply to the solution.

Implementation

Future<CreateSolutionResponse> createSolution({
  required String datasetGroupArn,
  required String name,
  String? eventType,
  bool? performAutoML,
  bool? performAutoTraining,
  bool? performHPO,
  bool? performIncrementalUpdate,
  String? recipeArn,
  SolutionConfig? solutionConfig,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonPersonalize.CreateSolution'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'datasetGroupArn': datasetGroupArn,
      'name': name,
      if (eventType != null) 'eventType': eventType,
      if (performAutoML != null) 'performAutoML': performAutoML,
      if (performAutoTraining != null)
        'performAutoTraining': performAutoTraining,
      if (performHPO != null) 'performHPO': performHPO,
      if (performIncrementalUpdate != null)
        'performIncrementalUpdate': performIncrementalUpdate,
      if (recipeArn != null) 'recipeArn': recipeArn,
      if (solutionConfig != null) 'solutionConfig': solutionConfig,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateSolutionResponse.fromJson(jsonResponse.body);
}