Amazon SageMaker提供了一种在批量转换作业中监控模型质量的方法。您可以使用Amazon SageMaker Model Monitor来监视批处理转换作业中的模型性能并检测模型性能的漂移。以下是使用Amazon SageMaker Model Monitor监控批处理转换作业的步骤示例:
from sagemaker.model_monitor.dataset_format import DatasetFormat
data_capture_format = DatasetFormat(
csv_format={
"header": True,
"delimiter": ",",
"quoteChar": '"',
"doubleQuote": True,
"escapeChar": "\\",
"nullValue": "?",
}
)
output_kms_key = "alias/aws/sagemaker"
from sagemaker.model_monitor import DataCaptureConfig
data_capture_config = DataCaptureConfig(
enable_capture=True,
sampling_percentage=100,
capture_options=["REQUEST", "RESPONSE"],
destination_s3_uri=f"s3://{s3_bucket}/{s3_prefix}",
kms_key_id=output_kms_key,
csv_content_types=["text/csv"],
json_content_types=["application/json"],
inference_response_capture_config=None,
probability_capture_config=None,
probability_threshold=0.0,
anchor_threshold=None,
capture_mode=None,
max_request_size=None,
max_response_size=None,
sagemaker_capture_duration=None,
enable_capture_upload=True,
sampling_direction="bottom",
json_format_for_request=None,
json_format_for_response=None,
dataset_format_type=None,
dataset_format_options=None,
csv_format_options=None,
)
transformer = model.transformer(
instance_count=1,
instance_type="ml.m5.large",
strategy="SingleRecord",
output_path=output_path,
output_kms_key=output_kms_key,
accept="text/csv",
env={
"SAGEMAKER_MODEL_SERVER_WAIT_TIME_SECONDS": "60",
},
max_payload=6,
tags=[{"Key": "stack_name", "Value":