文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DescribeDocumentClassifier
搭配 a AWS SDK 或 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 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeDocumentClassifier
。
-
- Python
-
- Python 的 SDK (Boto3)
-
注意
還有更多 on 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 SDK for Python (Boto3) Word 參考中的 API。
-
DescribeDocumentClassificationJob
DescribeTopicsDetectionJob