document_classifiers
Creates, updates, deletes, gets or lists a document_classifiers resource.
Overview
| Name | document_classifiers |
| Type | Resource |
| Id | aws.comprehend.document_classifiers |
Fields
The following fields are returned by SELECT queries:
- describe_document_classifier
- list_document_classifiers
| Name | Datatype | Description |
|---|---|---|
classifier_metadata | object | Information about the document classifier, including the number of documents used for training the classifier, the number of documents used for test the classifier, and an accuracy rating. |
data_access_role_arn | string | The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend read access to your input data. (pattern: <code>arn:aws(-[^:]+)?:iam::[0-9]{12}:role/.+</code>) |
document_classifier_arn | string | The Amazon Resource Name (ARN) that identifies the document classifier. (pattern: <code>arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]:[0-9]{12}:document-classifier/[a-zA-Z0-9](-[a-zA-Z0-9])(/version/[a-zA-Z0-9](-[a-zA-Z0-9])*)?</code>) |
end_time | string (date-time) | The time that training the document classifier completed. |
flywheel_arn | string | The Amazon Resource Number (ARN) of the flywheel (pattern: <code>arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]:[0-9]{12}:flywheel/[a-zA-Z0-9](-[a-zA-Z0-9])*</code>) |
input_data_config | object | The input data configuration that you supplied when you created the document classifier for training. |
language_code | string | The language code for the language of the documents that the classifier was trained on. (en, es, fr, de, it, pt, ar, hi, ja, ko, zh, zh-TW) |
message | string | Additional information about the status of the classifier. |
mode | string | Indicates the mode in which the specific classifier was trained. This also indicates the format of input documents and the format of the confusion matrix. Each classifier can only be trained in one mode and this cannot be changed once the classifier is trained. (MULTI_CLASS, MULTI_LABEL) |
model_kms_key_id | 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" (pattern: <code>^\p{ASCII}+$</code>) |
output_data_config | object | Provides output results configuration parameters for custom classifier jobs. |
source_model_arn | string | The Amazon Resource Name (ARN) of the source model. This model was imported from a different Amazon Web Services account to create the document classifier model in your Amazon Web Services account. (pattern: <code>arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]:[0-9]{12}:document-classifier/[a-zA-Z0-9](-[a-zA-Z0-9])(/version/[a-zA-Z0-9](-[a-zA-Z0-9])*)?</code>) |
status | string | The status of the document classifier. If the status is TRAINED the classifier is ready to use. If the status is TRAINED_WITH_WARNINGS the classifier training succeeded, but you should review the warnings returned in the CreateDocumentClassifier response. If the status is FAILED you can see additional information about why the classifier wasn't trained in the Message field. (SUBMITTED, TRAINING, DELETING, STOP_REQUESTED, STOPPED, IN_ERROR, TRAINED, TRAINED_WITH_WARNING) |
submit_time | string (date-time) | The time that the document classifier was submitted for training. |
training_end_time | string (date-time) | The time that training of the document classifier was completed. Indicates the time when the training completes on documentation classifiers. You are billed for the time interval between this time and the value of TrainingStartTime. |
training_start_time | string (date-time) | Indicates the time when the training starts on documentation classifiers. You are billed for the time interval between this time and the value of TrainingEndTime. |
version_name | string | The version name that you assigned to the document classifier. (pattern: <code>^[a-zA-Z0-9](-[a-zA-Z0-9])$</code>) |
volume_kms_key_id | string | ID for the Amazon Web Services Key Management Service (KMS) key that Amazon Comprehend uses to encrypt data on the storage volume attached to the ML compute instance(s) that process the analysis job. The VolumeKmsKeyId 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" (pattern: <code>^\p{ASCII}+$</code>) |
vpc_config | object | 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. |
| Name | Datatype | Description |
|---|---|---|
classifier_metadata | object | Information about the document classifier, including the number of documents used for training the classifier, the number of documents used for test the classifier, and an accuracy rating. |
data_access_role_arn | string | The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend read access to your input data. (pattern: <code>arn:aws(-[^:]+)?:iam::[0-9]{12}:role/.+</code>) |
document_classifier_arn | string | The Amazon Resource Name (ARN) that identifies the document classifier. (pattern: <code>arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]:[0-9]{12}:document-classifier/[a-zA-Z0-9](-[a-zA-Z0-9])(/version/[a-zA-Z0-9](-[a-zA-Z0-9])*)?</code>) |
end_time | string (date-time) | The time that training the document classifier completed. |
flywheel_arn | string | The Amazon Resource Number (ARN) of the flywheel (pattern: <code>arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]:[0-9]{12}:flywheel/[a-zA-Z0-9](-[a-zA-Z0-9])*</code>) |
input_data_config | object | The input data configuration that you supplied when you created the document classifier for training. |
language_code | string | The language code for the language of the documents that the classifier was trained on. (en, es, fr, de, it, pt, ar, hi, ja, ko, zh, zh-TW) |
message | string | Additional information about the status of the classifier. |
mode | string | Indicates the mode in which the specific classifier was trained. This also indicates the format of input documents and the format of the confusion matrix. Each classifier can only be trained in one mode and this cannot be changed once the classifier is trained. (MULTI_CLASS, MULTI_LABEL) |
model_kms_key_id | 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" (pattern: <code>^\p{ASCII}+$</code>) |
output_data_config | object | Provides output results configuration parameters for custom classifier jobs. |
source_model_arn | string | The Amazon Resource Name (ARN) of the source model. This model was imported from a different Amazon Web Services account to create the document classifier model in your Amazon Web Services account. (pattern: <code>arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]:[0-9]{12}:document-classifier/[a-zA-Z0-9](-[a-zA-Z0-9])(/version/[a-zA-Z0-9](-[a-zA-Z0-9])*)?</code>) |
status | string | The status of the document classifier. If the status is TRAINED the classifier is ready to use. If the status is TRAINED_WITH_WARNINGS the classifier training succeeded, but you should review the warnings returned in the CreateDocumentClassifier response. If the status is FAILED you can see additional information about why the classifier wasn't trained in the Message field. (SUBMITTED, TRAINING, DELETING, STOP_REQUESTED, STOPPED, IN_ERROR, TRAINED, TRAINED_WITH_WARNING) |
submit_time | string (date-time) | The time that the document classifier was submitted for training. |
training_end_time | string (date-time) | The time that training of the document classifier was completed. Indicates the time when the training completes on documentation classifiers. You are billed for the time interval between this time and the value of TrainingStartTime. |
training_start_time | string (date-time) | Indicates the time when the training starts on documentation classifiers. You are billed for the time interval between this time and the value of TrainingEndTime. |
version_name | string | The version name that you assigned to the document classifier. (pattern: <code>^[a-zA-Z0-9](-[a-zA-Z0-9])$</code>) |
volume_kms_key_id | string | ID for the Amazon Web Services Key Management Service (KMS) key that Amazon Comprehend uses to encrypt data on the storage volume attached to the ML compute instance(s) that process the analysis job. The VolumeKmsKeyId 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" (pattern: <code>^\p{ASCII}+$</code>) |
vpc_config | object | 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. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_document_classifier | select | region | Gets the properties associated with a document classifier. | |
list_document_classifiers | select | region | Gets a list of the document classifiers that you have created. | |
create_document_classifier | insert | region, DocumentClassifierName, DataAccessRoleArn, InputDataConfig, LanguageCode | Creates a new document classifier that you can use to categorize documents. To create a classifier, you provide a set of training documents that are labeled with the categories that you want to use. For more information, see Training classifier models in the Comprehend Developer Guide. | |
delete_document_classifier | delete | region | Deletes a previously created document classifier Only those classifiers that are in terminated states (IN_ERROR, TRAINED) will be deleted. If an active inference job is using the model, a ResourceInUseException will be returned. This is an asynchronous action that puts the classifier into a DELETING state, and it is then removed by a background job. Once removed, the classifier disappears from your account and is no longer available for use. | |
stop_training_document_classifier | exec | region, DocumentClassifierArn | Stops a document classifier training job while in progress. If the training job state is TRAINING, the job is marked for termination and put into the STOP_REQUESTED state. If the training job completes before it can be stopped, it is put into the TRAINED; otherwise the training job is stopped and put into the STOPPED state and the service sends back an HTTP 200 response with an empty HTTP body. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- describe_document_classifier
- list_document_classifiers
Gets the properties associated with a document classifier.
SELECT
classifier_metadata,
data_access_role_arn,
document_classifier_arn,
end_time,
flywheel_arn,
input_data_config,
language_code,
message,
mode,
model_kms_key_id,
output_data_config,
source_model_arn,
status,
submit_time,
training_end_time,
training_start_time,
version_name,
volume_kms_key_id,
vpc_config
FROM aws.comprehend.document_classifiers
WHERE region = '{{ region }}' -- required
;
Gets a list of the document classifiers that you have created.
SELECT
classifier_metadata,
data_access_role_arn,
document_classifier_arn,
end_time,
flywheel_arn,
input_data_config,
language_code,
message,
mode,
model_kms_key_id,
output_data_config,
source_model_arn,
status,
submit_time,
training_end_time,
training_start_time,
version_name,
volume_kms_key_id,
vpc_config
FROM aws.comprehend.document_classifiers
WHERE region = '{{ region }}' -- required
;
INSERT examples
- create_document_classifier
- Manifest
Creates a new document classifier that you can use to categorize documents. To create a classifier, you provide a set of training documents that are labeled with the categories that you want to use. For more information, see Training classifier models in the Comprehend Developer Guide.
INSERT INTO aws.comprehend.document_classifiers (
DocumentClassifierName,
VersionName,
DataAccessRoleArn,
Tags,
InputDataConfig,
OutputDataConfig,
ClientRequestToken,
LanguageCode,
VolumeKmsKeyId,
VpcConfig,
Mode,
ModelKmsKeyId,
ModelPolicy,
region
)
SELECT
'{{ DocumentClassifierName }}' /* required */,
'{{ VersionName }}',
'{{ DataAccessRoleArn }}' /* required */,
'{{ Tags }}',
'{{ InputDataConfig }}' /* required */,
'{{ OutputDataConfig }}',
'{{ ClientRequestToken }}',
'{{ LanguageCode }}' /* required */,
'{{ VolumeKmsKeyId }}',
'{{ VpcConfig }}',
'{{ Mode }}',
'{{ ModelKmsKeyId }}',
'{{ ModelPolicy }}',
'{{ region }}'
RETURNING
document_classifier_arn
;
# Description fields are for documentation purposes
- name: document_classifiers
props:
- name: region
value: "{{ region }}"
description: Required parameter for the document_classifiers resource.
- name: DocumentClassifierName
value: "{{ DocumentClassifierName }}"
description: |
The name of the document classifier.
- name: VersionName
value: "{{ VersionName }}"
description: |
The version name given to the newly created classifier. Version names can have a maximum of 256 characters. Alphanumeric characters, hyphens (-) and underscores (_) are allowed. The version name must be unique among all models with the same classifier name in the Amazon Web Services account/Amazon Web Services Region.
- name: DataAccessRoleArn
value: "{{ DataAccessRoleArn }}"
description: |
The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend read access to your input data.
- name: Tags
description: |
Tags to associate with the document classifier. A tag is a key-value pair that adds as a metadata to a resource used by Amazon Comprehend. For example, a tag with "Sales" as the key might be added to a resource to indicate its use by the sales department.
value:
- Key: "{{ Key }}"
Value: "{{ Value }}"
- name: InputDataConfig
description: |
Specifies the format and location of the input data for the job.
value:
DataFormat: "{{ DataFormat }}"
S3Uri: "{{ S3Uri }}"
TestS3Uri: "{{ TestS3Uri }}"
LabelDelimiter: "{{ LabelDelimiter }}"
AugmentedManifests:
- S3Uri: "{{ S3Uri }}"
Split: "{{ Split }}"
AttributeNames: "{{ AttributeNames }}"
AnnotationDataS3Uri: "{{ AnnotationDataS3Uri }}"
SourceDocumentsS3Uri: "{{ SourceDocumentsS3Uri }}"
DocumentType: "{{ DocumentType }}"
DocumentType: "{{ DocumentType }}"
Documents:
S3Uri: "{{ S3Uri }}"
TestS3Uri: "{{ TestS3Uri }}"
DocumentReaderConfig:
DocumentReadAction: "{{ DocumentReadAction }}"
DocumentReadMode: "{{ DocumentReadMode }}"
FeatureTypes:
- "{{ FeatureTypes }}"
- name: OutputDataConfig
description: |
Specifies the location for the output files from a custom classifier job. This parameter is required for a request that creates a native document model.
value:
S3Uri: "{{ S3Uri }}"
KmsKeyId: "{{ KmsKeyId }}"
FlywheelStatsS3Prefix: "{{ FlywheelStatsS3Prefix }}"
- name: ClientRequestToken
value: "{{ ClientRequestToken }}"
description: |
A unique identifier for the request. If you don't set the client request token, Amazon Comprehend generates one.
- name: LanguageCode
value: "{{ LanguageCode }}"
description: |
The language of the input documents. You can specify any of the languages supported by Amazon Comprehend. All documents must be in the same language.
valid_values: ['en', 'es', 'fr', 'de', 'it', 'pt', 'ar', 'hi', 'ja', 'ko', 'zh', 'zh-TW']
- name: VolumeKmsKeyId
value: "{{ VolumeKmsKeyId }}"
description: |
ID for the Amazon Web Services Key Management Service (KMS) key that Amazon Comprehend uses to encrypt data on the storage volume attached to the ML compute instance(s) that process the analysis job. The VolumeKmsKeyId 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"
- name: VpcConfig
description: |
Configuration parameters for an optional private Virtual Private Cloud (VPC) containing the resources you are using for your custom classifier. For more information, see Amazon VPC.
value:
SecurityGroupIds:
- "{{ SecurityGroupIds }}"
Subnets:
- "{{ Subnets }}"
- name: Mode
value: "{{ Mode }}"
description: |
Indicates the mode in which the classifier will be trained. The classifier can be trained in multi-class (single-label) mode or multi-label mode. Multi-class mode identifies a single class label for each document and multi-label mode identifies one or more class labels for each document. Multiple labels for an individual document are separated by a delimiter. The default delimiter between labels is a pipe (|).
valid_values: ['MULTI_CLASS', 'MULTI_LABEL']
- name: ModelKmsKeyId
value: "{{ ModelKmsKeyId }}"
description: |
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"
- name: ModelPolicy
value: "{{ ModelPolicy }}"
description: |
The resource-based policy to attach to your custom document classifier model. You can use this policy to allow another Amazon Web Services account to import your custom model. Provide your policy as a JSON body that you enter as a UTF-8 encoded string without line breaks. To provide valid JSON, enclose the attribute names and values in double quotes. If the JSON body is also enclosed in double quotes, then you must escape the double quotes that are inside the policy: "{"attribute": "value", "attribute": ["value"]}" To avoid escaping quotes, you can use single quotes to enclose the policy and double quotes to enclose the JSON names and values: '{"attribute": "value", "attribute": ["value"]}'
DELETE examples
- delete_document_classifier
Deletes a previously created document classifier Only those classifiers that are in terminated states (IN_ERROR, TRAINED) will be deleted. If an active inference job is using the model, a ResourceInUseException will be returned. This is an asynchronous action that puts the classifier into a DELETING state, and it is then removed by a background job. Once removed, the classifier disappears from your account and is no longer available for use.
DELETE FROM aws.comprehend.document_classifiers
WHERE region = '{{ region }}' --required
;
Lifecycle Methods
- stop_training_document_classifier
Stops a document classifier training job while in progress. If the training job state is TRAINING, the job is marked for termination and put into the STOP_REQUESTED state. If the training job completes before it can be stopped, it is put into the TRAINED; otherwise the training job is stopped and put into the STOPPED state and the service sends back an HTTP 200 response with an empty HTTP body.
EXEC aws.comprehend.document_classifiers.stop_training_document_classifier
@region='{{ region }}' --required
@@json=
'{
"DocumentClassifierArn": "{{ DocumentClassifierArn }}"
}'
;