DefaultModelMonitor: DefaultModelMonitor Class

DefaultModelMonitorR Documentation

DefaultModelMonitor Class

Description

Sets up Amazon SageMaker Monitoring Schedules and baseline suggestions. Use this class when you want to utilize Amazon SageMaker Monitoring's plug-and-play solution that only requires your dataset and optional pre/postprocessing scripts. For a more customized experience, consider using the ModelMonitor class instead.

Super class

sagemaker.mlcore::ModelMonitor -> DefaultModelMonitor

Public fields

JOB_DEFINITION_BASE_NAME

Model definition base name

Methods

Public methods

Inherited methods

Method new()

Initializes a “Monitor“ instance. The Monitor handles baselining datasets and creating Amazon SageMaker Monitoring Schedules to monitor SageMaker endpoints.

Usage
DefaultModelMonitor$new(
  role,
  instance_count = 1,
  instance_type = "ml.m5.xlarge",
  volume_size_in_gb = 30,
  volume_kms_key = NULL,
  output_kms_key = NULL,
  max_runtime_in_seconds = NULL,
  base_job_name = NULL,
  sagemaker_session = NULL,
  env = NULL,
  tags = NULL,
  network_config = NULL
)
Arguments
role

(str): An AWS IAM role name or ARN. The Amazon SageMaker jobs use this role.

instance_count

(int): The number of instances to run the jobs with.

instance_type

(str): Type of EC2 instance to use for the job, for example, 'ml.m5.xlarge'.

volume_size_in_gb

(int): Size in GB of the EBS volume to use for storing data during processing (default: 30).

volume_kms_key

(str): A KMS key for the processing volume.

output_kms_key

(str): The KMS key id for the job's outputs.

max_runtime_in_seconds

(int): Timeout in seconds. After this amount of time, Amazon SageMaker terminates the job regardless of its current status. Default: 3600

base_job_name

(str): Prefix for the job name. If not specified, a default name is generated based on the training image name and current timestamp.

sagemaker_session

(sagemaker.session.Session): Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created using the default AWS configuration chain.

env

(dict): Environment variables to be passed to the job.

tags

([dict]): List of tags to be passed to the job.

network_config

(sagemaker.network.NetworkConfig): A NetworkConfig object that configures network isolation, encryption of inter-container traffic, security group IDs, and subnets.


Method monitoring_type()

Type of the monitoring job.

Usage
DefaultModelMonitor$monitoring_type()

Method suggest_baseline()

Suggest baselines for use with Amazon SageMaker Model Monitoring Schedules.

Usage
DefaultModelMonitor$suggest_baseline(
  baseline_dataset,
  dataset_format,
  record_preprocessor_script = NULL,
  post_analytics_processor_script = NULL,
  output_s3_uri = NULL,
  wait = TRUE,
  logs = TRUE,
  job_name = NULL
)
Arguments
baseline_dataset

(str): The path to the baseline_dataset file. This can be a local path or an S3 uri.

dataset_format

(dict): The format of the baseline_dataset.

record_preprocessor_script

(str): The path to the record preprocessor script. This can be a local path or an S3 uri.

post_analytics_processor_script

(str): The path to the record post-analytics processor script. This can be a local path or an S3 uri.

output_s3_uri

(str): Desired S3 destination Destination of the constraint_violations and statistics json files. Default: "s3://<default_session_bucket>/<job_name>/output"

wait

(bool): Whether the call should wait until the job completes (default: True).

logs

(bool): Whether to show the logs produced by the job. Only meaningful when wait is True (default: True).

job_name

(str): Processing job name. If not specified, the processor generates a default job name, based on the image name and current timestamp.

Returns

sagemaker.processing.ProcessingJob: The ProcessingJob object representing the baselining job.


Method create_monitoring_schedule()

Creates a monitoring schedule to monitor an Amazon SageMaker Endpoint. If constraints and statistics are provided, or if they are able to be retrieved from a previous baselining job associated with this monitor, those will be used. If constraints and statistics cannot be automatically retrieved, baseline_inputs will be required in order to kick off a baselining job.

Usage
DefaultModelMonitor$create_monitoring_schedule(
  endpoint_input,
  record_preprocessor_script = NULL,
  post_analytics_processor_script = NULL,
  output_s3_uri = NULL,
  constraints = NULL,
  statistics = NULL,
  monitor_schedule_name = NULL,
  schedule_cron_expression = NULL,
  enable_cloudwatch_metrics = TRUE
)
Arguments
endpoint_input

(str or sagemaker.model_monitor.EndpointInput): The endpoint to monitor. This can either be the endpoint name or an EndpointInput.

record_preprocessor_script

(str): The path to the record preprocessor script. This can be a local path or an S3 uri.

post_analytics_processor_script

(str): The path to the record post-analytics processor script. This can be a local path or an S3 uri.

output_s3_uri

(str): Desired S3 destination of the constraint_violations and statistics json files. Default: "s3://<default_session_bucket>/<job_name>/output"

constraints

(sagemaker.model_monitor.Constraints or str): If provided alongside statistics, these will be used for monitoring the endpoint. This can be a sagemaker.model_monitor.Constraints object or an s3_uri pointing to a constraints JSON file.

statistics

(sagemaker.model_monitor.Statistic or str): If provided alongside constraints, these will be used for monitoring the endpoint. This can be a sagemaker.model_monitor.Constraints object or an s3_uri pointing to a constraints JSON file.

monitor_schedule_name

(str): Schedule name. If not specified, the processor generates a default job name, based on the image name and current timestamp.

schedule_cron_expression

(str): The cron expression that dictates the frequency that this job run. See sagemaker.model_monitor.CronExpressionGenerator for valid expressions. Default: Daily.

enable_cloudwatch_metrics

(bool): Whether to publish cloudwatch metrics as part of the baselining or monitoring jobs.


Method update_monitoring_schedule()

Updates the existing monitoring schedule.

Usage
DefaultModelMonitor$update_monitoring_schedule(
  endpoint_input = NULL,
  record_preprocessor_script = NULL,
  post_analytics_processor_script = NULL,
  output_s3_uri = NULL,
  statistics = NULL,
  constraints = NULL,
  schedule_cron_expression = NULL,
  instance_count = NULL,
  instance_type = NULL,
  volume_size_in_gb = NULL,
  volume_kms_key = NULL,
  output_kms_key = NULL,
  max_runtime_in_seconds = NULL,
  env = NULL,
  network_config = NULL,
  enable_cloudwatch_metrics = NULL,
  role = NULL
)
Arguments
endpoint_input

(str or sagemaker.model_monitor.EndpointInput): The endpoint to monitor. This can either be the endpoint name or an EndpointInput.

record_preprocessor_script

(str): The path to the record preprocessor script. This can be a local path or an S3 uri.

post_analytics_processor_script

(str): The path to the record post-analytics processor script. This can be a local path or an S3 uri.

output_s3_uri

(str): Desired S3 destination of the constraint_violations and statistics json files.

statistics

(sagemaker.model_monitor.Statistic or str): If provided alongside constraints, these will be used for monitoring the endpoint. This can be a sagemaker.model_monitor.Constraints object or an S3 uri pointing to a constraints JSON file.

constraints

(sagemaker.model_monitor.Constraints or str): If provided alongside statistics, these will be used for monitoring the endpoint. This can be a sagemaker.model_monitor.Constraints object or an S3 uri pointing to a constraints JSON file.

schedule_cron_expression

(str): The cron expression that dictates the frequency that this job runs at. See sagemaker.model_monitor.CronExpressionGenerator for valid expressions.

instance_count

(int): The number of instances to run the jobs with.

instance_type

(str): Type of EC2 instance to use for the job, for example, 'ml.m5.xlarge'.

volume_size_in_gb

(int): Size in GB of the EBS volume to use for storing data during processing (default: 30).

volume_kms_key

(str): A KMS key for the job's volume.

output_kms_key

(str): The KMS key id for the job's outputs.

max_runtime_in_seconds

(int): Timeout in seconds. After this amount of time, Amazon SageMaker terminates the job regardless of its current status. Default: 3600

env

(dict): Environment variables to be passed to the job.

network_config

(sagemaker.network.NetworkConfig): A NetworkConfig object that configures network isolation, encryption of inter-container traffic, security group IDs, and subnets.

enable_cloudwatch_metrics

(bool): Whether to publish cloudwatch metrics as part of the baselining or monitoring jobs.

role

(str): An AWS IAM role name or ARN. The Amazon SageMaker jobs use this role.


Method delete_monitoring_schedule()

Deletes the monitoring schedule and its job definition.

Usage
DefaultModelMonitor$delete_monitoring_schedule()

Method run_baseline()

'run_baseline()' is only allowed for ModelMonitor objects. Please use suggest_baseline for DefaultModelMonitor objects, instead.

Usage
DefaultModelMonitor$run_baseline()

Method attach()

Sets this object's schedule name to point to the Amazon Sagemaker Monitoring Schedule name provided. This allows subsequent describe_schedule or list_executions calls to point to the given schedule.

Usage
DefaultModelMonitor$attach(monitor_schedule_name, sagemaker_session = NULL)
Arguments
monitor_schedule_name

(str): The name of the schedule to attach to.

sagemaker_session

(sagemaker.session.Session): Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created using the default AWS configuration chain.


Method latest_monitoring_statistics()

Returns the sagemaker.model_monitor.Statistics generated by the latest monitoring execution.

Usage
DefaultModelMonitor$latest_monitoring_statistics()
Returns

sagemaker.model_monitoring.Statistics: The Statistics object representing the file generated by the latest monitoring execution.


Method latest_monitoring_constraint_violations()

Returns the sagemaker.model_monitor.ConstraintViolations generated by the latest monitoring execution.

Usage
DefaultModelMonitor$latest_monitoring_constraint_violations()
Returns

sagemaker.model_monitoring.ConstraintViolations: The ConstraintViolations object representing the file generated by the latest monitoring execution.


Method clone()

The objects of this class are cloneable with this method.

Usage
DefaultModelMonitor$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


DyfanJones/sagemaker-r-mlcore documentation built on May 3, 2022, 10:08 a.m.