選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

排定監控工作

焦點模式
排定監控工作 - Amazon SageMaker AI

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Amazon SageMaker Model Monitor 可讓您監控從即時端點收集到的資料。您可以按照週期性排程來監控資料,也可以立即監控一次資料。您可以使用 CreateMonitoringSchedule API 建立監控排程。

透過監控排程,SageMaker AI 可以開始處理任務,以分析在指定期間收集的資料。在處理任務中,SageMaker AI 會將目前分析的資料集與您提供的基準統計資料和限制條件進行比較。然後,SageMaker AI 會產生違規報告。此外,也會針對所分析的每個特徵發出 CloudWatch 指標。

SageMaker AI 提供預先建置的容器,用於對表格式資料集執行分析。或者,您可以選擇使用自有容器,如使用 Amazon SageMaker Model Monitor 支援您自己的容器主題所述。

您可以為即時端點或批次轉換工作建立模型監控排程。使用基準資源 (限制條件和統計資料),與即時流量或批次工作輸入進行比較。

範例 基準指派

在下列範例中,用來訓練模型的訓練資料集已上傳至 Amazon S3。如果您在 Amazon S3 中已有此資料集,則可以直接指向它。

# copy over the training dataset to Amazon S3 (if you already have it in Amazon S3, you could reuse it) baseline_prefix = prefix + '/baselining' baseline_data_prefix = baseline_prefix + '/data' baseline_results_prefix = baseline_prefix + '/results' baseline_data_uri = 's3://{}/{}'.format(bucket,baseline_data_prefix) baseline_results_uri = 's3://{}/{}'.format(bucket, baseline_results_prefix) print('Baseline data uri: {}'.format(baseline_data_uri)) print('Baseline results uri: {}'.format(baseline_results_uri))
training_data_file = open("test_data/training-dataset-with-header.csv", 'rb') s3_key = os.path.join(baseline_prefix, 'data', 'training-dataset-with-header.csv') boto3.Session().resource('s3').Bucket(bucket).Object(s3_key).upload_fileobj(training_data_file)
範例 週期性分析的排程

如果正在為即時端點排程模型監控,使用基準限制條件和統計資料,與即時流量進行比較。下列程式碼片段顯示您用來為即時端點排程模型監控的一般格式。此範例將模型監控排程為每小時執行一次。

from sagemaker.model_monitor import CronExpressionGenerator from time import gmtime, strftime mon_schedule_name = 'my-model-monitor-schedule-' + strftime("%Y-%m-%d-%H-%M-%S", gmtime()) my_default_monitor.create_monitoring_schedule( monitor_schedule_name=mon_schedule_name, endpoint_input=EndpointInput( endpoint_name=endpoint_name, destination="/opt/ml/processing/input/endpoint" ), post_analytics_processor_script=s3_code_postprocessor_uri, output_s3_uri=s3_report_path, statistics=my_default_monitor.baseline_statistics(), constraints=my_default_monitor.suggested_constraints(), schedule_cron_expression=CronExpressionGenerator.hourly(), enable_cloudwatch_metrics=True, )
範例 排程一次性分析

您也可以將下列引數傳遞至 create_monitoring_schedule 方法,將分析排程為執行一次而非週期性執行:

schedule_cron_expression=CronExpressionGenerator.now(), data_analysis_start_time="-PT1H", data_analysis_end_time="-PT0H",

在這些引數中,schedule_cron_expression 參數會將分析排程為使用值 CronExpressionGenerator.now() 立即執行一次。對於透過此設定的任何排程,data_analysis_start_timedata_analysis_end_time 參數都為必要。這些參數會設定分析時段的開始時間和結束時間。將這些時間定義為相對於目前時間的偏移,並使用 ISO 8601 持續時間格式。在這個範例中,時間 -PT1H-PT0H 定義在過去一小時和目前時間之間的時段。透過此排程,分析只會評估在指定時段期間收集的資料。

範例 排程批次轉換工作

下列程式碼片段顯示您用來排程批次轉換工作之模型監控的一般格式。

from sagemaker.model_monitor import ( CronExpressionGenerator, BatchTransformInput, MonitoringDatasetFormat, ) from time import gmtime, strftime mon_schedule_name = 'my-model-monitor-schedule-' + strftime("%Y-%m-%d-%H-%M-%S", gmtime()) my_default_monitor.create_monitoring_schedule( monitor_schedule_name=mon_schedule_name, batch_transform_input=BatchTransformInput( destination="opt/ml/processing/input", data_captured_destination_s3_uri=s3_capture_upload_path, dataset_format=MonitoringDatasetFormat.csv(header=False), ), post_analytics_processor_script=s3_code_postprocessor_uri, output_s3_uri=s3_report_path, statistics=my_default_monitor.baseline_statistics(), constraints=my_default_monitor.suggested_constraints(), schedule_cron_expression=CronExpressionGenerator.hourly(), enable_cloudwatch_metrics=True, )
desc_schedule_result = my_default_monitor.describe_schedule() print('Schedule status: {}'.format(desc_schedule_result['MonitoringScheduleStatus']))
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。