createDataset method

Future<CreateDatasetResponse> createDataset({
  1. required String datasetGroupArn,
  2. required String datasetType,
  3. required String name,
  4. required String schemaArn,
  5. List<Tag>? tags,
})

Creates an empty dataset and adds it to the specified dataset group. Use CreateDatasetImportJob to import your training data to a dataset.

There are 5 types of datasets:

  • Item interactions
  • Items
  • Users
  • Action interactions
  • Actions
Each dataset type has an associated schema with required field types. Only the Item interactions dataset is required in order to train a model (also referred to as creating a solution).

A dataset 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 dataset, call DescribeDataset.

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 to add the dataset to.

Parameter datasetType : The type of dataset.

One of the following (case insensitive) values:

  • Interactions
  • Items
  • Users
  • Actions
  • Action_Interactions

Parameter name : The name for the dataset.

Parameter schemaArn : The ARN of the schema to associate with the dataset. The schema defines the dataset fields.

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

Implementation

Future<CreateDatasetResponse> createDataset({
  required String datasetGroupArn,
  required String datasetType,
  required String name,
  required String schemaArn,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonPersonalize.CreateDataset'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'datasetGroupArn': datasetGroupArn,
      'datasetType': datasetType,
      'name': name,
      'schemaArn': schemaArn,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateDatasetResponse.fromJson(jsonResponse.body);
}