Comprehend / Client / create_flywheel

create_flywheel#

Comprehend.Client.create_flywheel(**kwargs)#

A flywheel is an Amazon Web Services resource that orchestrates the ongoing training of a model for custom classification or custom entity recognition. You can create a flywheel to start with an existing trained model, or Comprehend can create and train a new model.

When you create the flywheel, Comprehend creates a data lake in your account. The data lake holds the training data and test data for all versions of the model.

To use a flywheel with an existing trained model, you specify the active model version. Comprehend copies the model’s training data and test data into the flywheel’s data lake.

To use the flywheel with a new model, you need to provide a dataset for training data (and optional test data) when you create the flywheel.

For more information about flywheels, see Flywheel overview in the Amazon Comprehend Developer Guide.

See also: AWS API Documentation

Request Syntax

response = client.create_flywheel(
    FlywheelName='string',
    ActiveModelArn='string',
    DataAccessRoleArn='string',
    TaskConfig={
        'LanguageCode': 'en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW',
        'DocumentClassificationConfig': {
            'Mode': 'MULTI_CLASS'|'MULTI_LABEL',
            'Labels': [
                'string',
            ]
        },
        'EntityRecognitionConfig': {
            'EntityTypes': [
                {
                    'Type': 'string'
                },
            ]
        }
    },
    ModelType='DOCUMENT_CLASSIFIER'|'ENTITY_RECOGNIZER',
    DataLakeS3Uri='string',
    DataSecurityConfig={
        'ModelKmsKeyId': 'string',
        'VolumeKmsKeyId': 'string',
        'DataLakeKmsKeyId': 'string',
        'VpcConfig': {
            'SecurityGroupIds': [
                'string',
            ],
            'Subnets': [
                'string',
            ]
        }
    },
    ClientRequestToken='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
Parameters:
  • FlywheelName (string) –

    [REQUIRED]

    Name for the flywheel.

  • ActiveModelArn (string) – To associate an existing model with the flywheel, specify the Amazon Resource Number (ARN) of the model version. Do not set TaskConfig or ModelType if you specify an ActiveModelArn.

  • DataAccessRoleArn (string) –

    [REQUIRED]

    The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend the permissions required to access the flywheel data in the data lake.

  • TaskConfig (dict) –

    Configuration about the model associated with the flywheel. You need to set TaskConfig if you are creating a flywheel for a new model.

    • LanguageCode (string) – [REQUIRED]

      Language code for the language that the model supports.

    • DocumentClassificationConfig (dict) –

      Configuration required for a document classification model.

      • Mode (string) – [REQUIRED]

        Classification mode indicates whether the documents are MULTI_CLASS or MULTI_LABEL.

      • Labels (list) –

        One or more labels to associate with the custom classifier.

        • (string) –

    • EntityRecognitionConfig (dict) –

      Configuration required for an entity recognition model.

      • EntityTypes (list) – [REQUIRED]

        Up to 25 entity types that the model is trained to recognize.

        • (dict) –

          An entity type within a labeled training dataset that Amazon Comprehend uses to train a custom entity recognizer.

          • Type (string) – [REQUIRED]

            An entity type within a labeled training dataset that Amazon Comprehend uses to train a custom entity recognizer.

            Entity types must not contain the following invalid characters: n (line break), \n (escaped line break, r (carriage return), \r (escaped carriage return), t (tab), \t (escaped tab), and , (comma).

  • ModelType (string) – The model type. You need to set ModelType if you are creating a flywheel for a new model.

  • DataLakeS3Uri (string) –

    [REQUIRED]

    Enter the S3 location for the data lake. You can specify a new S3 bucket or a new folder of an existing S3 bucket. The flywheel creates the data lake at this location.

  • DataSecurityConfig (dict) –

    Data security configurations.

    • ModelKmsKeyId (string) –

      ID for the KMS key that Amazon Comprehend uses to encrypt trained custom models. The ModelKmsKeyId can be either of the following formats:

      • KMS Key ID: "1234abcd-12ab-34cd-56ef-1234567890ab"

      • Amazon Resource Name (ARN) of a KMS Key: "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"

    • VolumeKmsKeyId (string) –

      ID for the KMS key that Amazon Comprehend uses to encrypt the volume.

    • DataLakeKmsKeyId (string) –

      ID for the KMS key that Amazon Comprehend uses to encrypt the data in the data lake.

    • VpcConfig (dict) –

      Configuration parameters for an optional private Virtual Private Cloud (VPC) containing the resources you are using for the job. For more information, see Amazon VPC.

      • SecurityGroupIds (list) – [REQUIRED]

        The ID number for a security group on an instance of your private VPC. Security groups on your VPC function serve as a virtual firewall to control inbound and outbound traffic and provides security for the resources that you’ll be accessing on the VPC. This ID number is preceded by “sg-”, for instance: “sg-03b388029b0a285ea”. For more information, see Security Groups for your VPC.

        • (string) –

      • Subnets (list) – [REQUIRED]

        The ID for each subnet being used in your private VPC. This subnet is a subset of the a range of IPv4 addresses used by the VPC and is specific to a given availability zone in the VPC’s Region. This ID number is preceded by “subnet-”, for instance: “subnet-04ccf456919e69055”. For more information, see VPCs and Subnets.

        • (string) –

  • ClientRequestToken (string) –

    A unique identifier for the request. If you don’t set the client request token, Amazon Comprehend generates one.

    This field is autopopulated if not provided.

  • Tags (list) –

    The tags to associate with this flywheel.

    • (dict) –

      A key-value pair that adds as a metadata to a resource used by Amazon Comprehend. For example, a tag with the key-value pair ‘Department’:’Sales’ might be added to a resource to indicate its use by a particular department.

      • Key (string) – [REQUIRED]

        The initial part of a key-value pair that forms a tag associated with a given resource. For instance, if you want to show which resources are used by which departments, you might use “Department” as the key portion of the pair, with multiple possible values such as “sales,” “legal,” and “administration.”

      • Value (string) –

        The second part of a key-value pair that forms a tag associated with a given resource. For instance, if you want to show which resources are used by which departments, you might use “Department” as the initial (key) portion of the pair, with a value of “sales” to indicate the sales department.

Return type:

dict

Returns:

Response Syntax

{
    'FlywheelArn': 'string',
    'ActiveModelArn': 'string'
}

Response Structure

  • (dict) –

    • FlywheelArn (string) –

      The Amazon Resource Number (ARN) of the flywheel.

    • ActiveModelArn (string) –

      The Amazon Resource Number (ARN) of the active model version.

Exceptions