AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或DescribeDocumentClassifier
一起使用 CLI
以下代码示例演示如何使用 DescribeDocumentClassifier
。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- CLI
-
- AWS CLI
-
描述文档分类器
以下
describe-document-classifier
示例将获取自定义文档分类器模型的属性。aws comprehend describe-document-classifier \ --document-classifier-arn
arn:aws:comprehend:us-west-2:111122223333:document-classifier/example-classifier-1
输出:
{ "DocumentClassifierProperties": { "DocumentClassifierArn": "arn:aws:comprehend:us-west-2:111122223333:document-classifier/example-classifier-1", "LanguageCode": "en", "Status": "TRAINED", "SubmitTime": "2023-06-13T19:04:15.735000+00:00", "EndTime": "2023-06-13T19:42:31.752000+00:00", "TrainingStartTime": "2023-06-13T19:08:20.114000+00:00", "TrainingEndTime": "2023-06-13T19:41:35.080000+00:00", "InputDataConfig": { "DataFormat": "COMPREHEND_CSV", "S3Uri": "s3://DOC-EXAMPLE-BUCKET/trainingdata" }, "OutputDataConfig": {}, "ClassifierMetadata": { "NumberOfLabels": 3, "NumberOfTrainedDocuments": 5016, "NumberOfTestDocuments": 557, "EvaluationMetrics": { "Accuracy": 0.9856, "Precision": 0.9919, "Recall": 0.9459, "F1Score": 0.9673, "MicroPrecision": 0.9856, "MicroRecall": 0.9856, "MicroF1Score": 0.9856, "HammingLoss": 0.0144 } }, "DataAccessRoleArn": "arn:aws:iam::111122223333:role/service-role/AmazonComprehendServiceRole-example-role", "Mode": "MULTI_CLASS" } }
有关更多信息,请参阅《Amazon Comprehend 开发人员指南》中的创建和管理自定义模型。
-
有关API详细信息,请参阅 “DescribeDocumentClassifier AWS CLI
命令参考”。
-
- Python
-
- SDK适用于 Python (Boto3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 class ComprehendClassifier: """Encapsulates an Amazon Comprehend custom classifier.""" def __init__(self, comprehend_client): """ :param comprehend_client: A Boto3 Comprehend client. """ self.comprehend_client = comprehend_client self.classifier_arn = None def describe(self, classifier_arn=None): """ Gets metadata about a custom classifier, including its current status. :param classifier_arn: The ARN of the classifier to look up. :return: Metadata about the classifier. """ if classifier_arn is not None: self.classifier_arn = classifier_arn try: response = self.comprehend_client.describe_document_classifier( DocumentClassifierArn=self.classifier_arn ) classifier = response["DocumentClassifierProperties"] logger.info("Got classifier %s.", self.classifier_arn) except ClientError: logger.exception("Couldn't get classifier %s.", self.classifier_arn) raise else: return classifier
-
有关API详细信息,请参阅DescribeDocumentClassifier中的 AWS SDKPython (Boto3) API 参考。
-
DescribeDocumentClassificationJob
DescribeTopicsDetectionJob