Sagemaker Model Monitor - Best Practices and gotchas

Tech With Neelam Koshiya
21 Jun 202318:30

Summary

TLDRIn this episode of 'Tech with Nila', viewers are introduced to advanced practices for utilizing Amazon SageMaker Model Monitor, a tool for tracking data and model quality. The session assumes a pre-existing understanding of Model Monitor and discusses its integration with SageMaker Clarify for bias and explainability reports. The video outlines the types of monitoring available, the process of setting up baselines, and the importance of real-time monitoring with ground truth labels. It also touches on customization options, limitations, and the benefits of SageMaker's managed services for ML engineers and data scientists.

Takeaways

  • 🛠️ SageMaker Model Monitor is an advanced tool for monitoring data quality, model quality, and bias in machine learning models, requiring at least a level 200 understanding of the service.
  • 🔗 SageMaker Clarify and Model Monitor can be used together, with Clarify providing bias and explainability reports, and Model Monitor performing ongoing monitoring tasks.
  • 📈 Model Monitor categorizes monitoring into two types: one requiring ground truth labels for model quality and bias drift, and one not requiring ground truth for data quality and feature attribution drift.
  • 📊 To set up Model Monitor, you first create a baseline from the training dataset, which computes metrics and constraints, followed by scheduling monitoring jobs for ongoing data capture and analysis.
  • 📝 For monitoring jobs that require ground truth, an additional ETL process is needed to merge production data with true labels before Model Monitor can compare and report discrepancies.
  • 👥 Different personas prefer different access methods; machine learning engineers or data scientists might prefer AWS SDKs and CLI, while business analysts might prefer the SageMaker UI.
  • 🚫 Limitations exist with the UI, such as the inability to delete endpoints with Model Monitor enabled directly from the console, requiring CLI or API use instead.
  • 📊 Model Monitor computes metrics and statistics for tabular data only, meaning it can work with image classification models but will focus on output analysis rather than input.
  • ⚙️ Custom VPC configurations may be needed for SageMaker Studio launched in a custom Amazon VPC to ensure Model Monitor can communicate with necessary AWS services.
  • 💻 Pre-processing and post-processing scripts can be used with Model Monitor to transform data or extend monitoring capabilities, but are limited to data and model quality jobs.
  • 🔄 Real-time monitoring can be achieved by quickly generating ground truth labels, potentially using Amazon's Augmented AI service to add human-in-the-loop capabilities.
  • 🔄 Automating actions based on Model Monitor's alerts and data is crucial for effective deployment and ensures continuous model performance monitoring and improvement.

Q & A

  • What is the prerequisite knowledge required for this session on SageMaker Model Monitor?

    -The prerequisite knowledge for this session is at least a level 200 understanding of Model Monitor.

  • What does SageMaker Clarify provide in the context of model monitoring?

    -SageMaker Clarify is a container that produces bias and explainability reports, which can be used independently or in conjunction with SageMaker Model Monitor for recurring monitoring tasks.

  • What are the two types of monitoring jobs in SageMaker Model Monitor that require the help of SageMaker Clarify?

    -The two types of monitoring jobs that require SageMaker Clarify are model quality drift and bias drift, as they both need to compute final matrices based on ground truth labels.

  • How does SageMaker Model Monitor categorize the monitoring process?

    -SageMaker Model Monitor categorizes the monitoring process into two types: one that requires ground truth and one that does not require ground truth.

  • What is the first step in the monitoring process when using SageMaker Model Monitor?

    -The first step is to create a baseline from the dataset used to train the model, which computes the matrices and suggested constraints for the matrices.

  • What are the limitations of using the SageMaker UI for model monitoring?

    -Using the SageMaker UI, certain actions like deleting an interface endpoint with model monitoring enabled cannot be done directly in the console and require CLI or API usage.

  • How does SageMaker Model Monitor handle data capture for non-tabular data like images?

    -For non-tabular data like images, SageMaker Model Monitor calculates matrices and statistics for the output (the label based on the image), not the input.

  • What is the recommended disk utilization percentage to ensure continuous data capture by SageMaker Model Monitor?

    -It is recommended to keep disk utilization below 75% to ensure continuous data capture by SageMaker Model Monitor.

  • How can real-time monitoring be achieved with SageMaker Model Monitor?

    -Real-time monitoring can be achieved by quickly generating ground truth labels, which can be facilitated by leveraging Amazon's Augmented AI service to add human-in-the-loop capabilities.

  • What customization options does SageMaker Model Monitor offer for pre-processing and post-processing?

    -SageMaker Model Monitor allows the use of plain Python scripts for pre-processing to transform input data or for post-processing to extend the code after a successful monitoring run. This can be used for data transformation, feature exclusion, or applying custom sampling strategies.

  • What are the requirements for creating a data quality baseline in SageMaker Model Monitor?

    -For a data quality baseline, the schema of the training dataset and inference dataset should be the same, with the same number and order of features. The first column should refer to the prediction or output, and column names should use lowercase letters and underscores only.

  • How can the generated constraints from the baseline job be reviewed and modified?

    -The generated constraints can be reviewed and modified based on domain and business understanding to make the constraints more aggressive or relaxed, controlling the number and nature of violations.

  • What is the significance of setting start and end time offsets in monitoring jobs that require ground truth?

    -Start and end time offsets are important to select the relevant data for monitoring jobs that require ground truth, ensuring that only data for which the ground truth is available is used.

  • How can SageMaker Pipeline be used for on-demand model monitoring?

    -SageMaker Pipeline can be used to set up on-demand monitoring jobs by leveraging the 'check_job_config' method for quality checks and 'clarify_check_config' for bias and explainability checks, making it serverless and cost-effective.

  • What are the extension points provided by SageMaker Model Monitor for bringing your own container?

    -SageMaker Model Monitor provides extension points that allow you to adhere to the contract input and output to leverage the model monitor. The container can analyze data in the 'dataset_source_path' and write the report to the 'output_path', with the ability to write any report that suits your needs.

  • How can the data from SageMaker Model Monitor be used to automate actions like model retraining?

    -The data from SageMaker Model Monitor can trigger CloudWatch alarms and EventBridge rules when drifts are detected and matrix constraints are exceeded, which can in turn start a model retraining pipeline, automating the retraining process based on monitoring violations.

Outlines

00:00

📚 Introduction to SageMaker Model Monitor Best Practices

This paragraph introduces the video's focus on best practices for using Amazon SageMaker's Model Monitor. It sets the prerequisite of having at least a 200-level knowledge of Model Monitor and clarifies that the session is advanced. The speaker invites viewers to comment for a basic overview if needed. The paragraph outlines the types of monitoring available, such as data quality, model quality metrics, and feature attribution drift. It also introduces SageMaker Clarify, a tool for generating bias and explainability reports, and explains its relationship with Model Monitor. The paragraph concludes by detailing the working process of Model Monitor, distinguishing between monitoring types that require ground truth and those that do not.

05:02

🛠 Model Monitor Limitations and Data Capture Considerations

The second paragraph discusses limitations of the SageMaker Model Monitor, particularly when using the UI for deleting endpoints with enabled monitoring schedules, which must be done via CLI or API due to UI restrictions. It also covers the model monitor's capabilities, such as computing model metrics and statistics on tabular data only, and its current lack of support for multi-model endpoints. Additionally, the paragraph addresses the importance of setting up a VPC endpoint for SageMaker Studio in a custom Amazon VPC and provides guidelines for data capture, including region consistency and disk utilization thresholds to ensure continuous data capture for monitoring.

10:04

🔍 Deep Dive into Model Monitor's Baseline and Customization

This paragraph provides an in-depth look at creating a baseline for Model Monitor, which is crucial for monitoring data and model quality, bias, and explainability. It outlines the requirements and best practices for different types of baselines, emphasizing the importance of schema consistency between training and inference datasets. The paragraph also discusses the use of the kernel SHAP algorithm for feature attribution drift and the trade-offs involved. It explains how to review and adapt baseline constraints generated by Model Monitor to suit specific use cases, and how to schedule monitoring jobs for real-time endpoints and batch transforms, including on-demand monitoring through SageMaker pipelines.

15:06

🚀 Automating Model Retraining with SageMaker Model Monitor

The final paragraph highlights the importance of effective deployment and model monitoring for continuous oversight of model performance. It describes how to automate actions based on the data collected by Model Monitor, using an example architecture that triggers a retraining pipeline when data drift is detected and model metrics exceed predefined thresholds. The paragraph emphasizes the power of SageMaker Model Monitor as a fully managed tool and encourages viewers to leverage it, while also inviting feedback on the discussed best practices.

Mindmap

Keywords

💡SageMaker

SageMaker is an Amazon Web Services (AWS) product that provides a cloud-based machine learning platform. It enables developers and data scientists to build, train, and deploy machine learning models quickly. In the video's context, SageMaker is the platform on which model monitoring and model quality assessments are conducted, emphasizing its role in the machine learning lifecycle.

💡Model Monitor

Model Monitor is a feature within SageMaker that continuously assesses the performance and quality of machine learning models in production. It helps detect issues such as data drift and model bias. In the script, Model Monitor is the central tool discussed for ensuring the ongoing reliability and accuracy of deployed models.

💡Data Quality

Data quality refers to the overall integrity and reliability of the data used in machine learning models. High data quality is crucial for the accuracy of model predictions. The script mentions data quality monitoring as one of the key functions of SageMaker's Model Monitor, indicating its importance in maintaining model performance over time.

💡Model Quality Matrix

A model quality matrix is a set of metrics used to evaluate the performance of a machine learning model, such as accuracy, precision, and recall. In the video, the Model Monitor is described as monitoring these metrics to ensure the model's predictions remain within acceptable parameters.

💡Data Drift

Data drift occurs when the statistical properties of the input data to a model change over time, which can affect the model's performance. The script discusses data quality drift as a type of monitoring provided by Model Monitor to detect and alert on such changes.

💡Feature Attribution Drift

Feature attribution drift refers to changes in the importance or contribution of individual features to the model's predictions over time. The script mentions monitoring this to ensure that the model's decision-making process remains consistent and reliable.

💡SageMaker Clarify

SageMaker Clarify is a tool within the SageMaker suite that helps in detecting bias and providing an explainability report for machine learning models. The script explains that Clarify can be used in conjunction with Model Monitor for ongoing monitoring of model bias.

💡Ground Truth

Ground truth in the context of machine learning refers to the actual correct labels or outcomes against which model predictions are compared. The script discusses the need for ground truth labels in certain types of model monitoring, such as model quality drift and bias drift, to compute the final metrics.

💡Pre-processing

Pre-processing in machine learning involves transforming raw data into a format suitable for model consumption. The script mentions the use of pre-processing scripts in Model Monitor to transform input data into a structure that can be analyzed, such as converting arrays into JSON format.

💡Post-processing

Post-processing is the process of extending or modifying the output of a machine learning model after its initial run. The script suggests using post-processing scripts to extend the code following a monitoring run, such as triggering an ETL process or calling an API.

💡Baseline

A baseline in the context of model monitoring is a reference point or standard set of metrics and constraints derived from the data used to train the model. The script explains that creating a baseline is the first step in monitoring data and model quality, and it's used for comparison against production data.

💡Bias Drift

Bias drift refers to changes in the fairness or bias of a model's predictions over time. The script discusses monitoring for bias drift to ensure that the model remains unbiased with respect to sensitive attributes, such as those related to protected characteristics.

💡CloudWatch

Amazon CloudWatch is a monitoring service for AWS cloud resources and applications. The script mentions CloudWatch as a destination for sending violation reports generated by Model Monitor, which can trigger alarms and automated actions.

💡S3

Amazon S3 (Simple Storage Service) is a scalable object storage service. The script refers to S3 as a storage location for ground truth labels and as a place where Model Monitor stores its reports and results.

Highlights

Introduction to best practices for using SageMaker Model Monitor.

Prerequisite of having at least level 200 knowledge of Model Monitor.

Explanation of SageMaker Model Monitor's capabilities for data and model quality monitoring.

Clarification on the relationship between SageMaker Clarify and Model Monitor.

Use of SageMaker Clarify for producing bias and explainability reports.

Model Monitor's role in recurring monitoring of models and data.

Different types of monitoring categorized into those needing ground truth and those not needing it.

Process summary of creating a baseline, scheduling monitoring jobs, and comparing matrices.

Importance of ground truth in model quality drift and bias drift monitoring.

ETL process setup for merging production data with ground truth labels.

Different access mechanisms for machine learning engineers, data scientists, business analysts, and data analysts.

Limitations of using SageMaker UI for certain operations like deleting endpoints.

Model Monitor's support for only tabular data and not for image classification models' input.

Current limitations on monitoring multi-model endpoints and support for batch transform.

Requirements for setting up a VPC endpoint for SageMaker Studio in a custom Amazon VPC.

Guidelines on managing disk utilization for continuous data capture.

Use of Amazon's Augmented AI service for real-time monitoring by generating ground truth labels.

Customization options in Model Monitor for pre-processing and post-processing scripts.

Best practices for setting up a data quality baseline with considerations for schema and feature order.

Model quality monitoring setup requiring access to datasets with ground truth labels.

Feature attribution drift measurement using the kernel shuffle algorithm and considerations for surrogate model complexity.

Bias drift baseline setup with configuration options for label value, threshold, facet name, and facet value.

Automated processing job for computing statistics and constraints for the baseline.

Importance of reviewing and adapting baseline constraints based on domain understanding.

Scheduling monitoring for real-time endpoints and considerations for ground truth availability.

Use of SageMaker Pipeline for setting up on-demand monitoring jobs.

Extension points for bringing your own container to leverage Model Monitor for custom use cases.

Automating actions based on Model Monitor alerts for continuous model improvement.

Transcripts

play00:01

hello everybody and welcome to the new

play00:03

episode of tech with Nila so in today's

play00:07

session we are going to talk about uh

play00:09

best practices of using CH maker model

play00:12

monitoring now the prerequisite of this

play00:16

is you need to have at least level 200

play00:18

level knowledge of model monitor so to

play00:21

make a model Monitor and this is a

play00:23

little bit advanced

play00:25

session for those who are already aware

play00:27

of the model monitor but if you feel

play00:30

that you need to have a level 200

play00:32

session or just a basic overview of what

play00:35

sagemaker model monitor is and maybe do

play00:39

a demo Etc please comment on my video

play00:41

thank you so let's get started

play00:46

model monitor provides the following

play00:49

types of monitoring so it'll help you to

play00:51

monitor just in the data quality

play00:53

drift in the model quality Matrix such

play00:56

as

play00:58

accuracy

play01:02

and monitor the buyers in your model

play01:06

prediction or monitor drift in the

play01:08

feature attribution

play01:10

now if you take a look at the sagemaker

play01:12

model Monitor and if you go through the

play01:14

documentation there's a mention of CH

play01:17

maker clarify in conjunction with model

play01:19

Monitor and you'll be thinking what what

play01:21

is happening here so let's let's talk a

play01:25

little bit more about it right

play01:30

so sagemaker clarify is essentially a

play01:34

container that produces the bias and

play01:36

experimulatory report and chpco monitor

play01:39

is actually a service which performs

play01:41

these recurring monitoring on the models

play01:44

and the data which is captured from the

play01:46

endpoint or the bad transform job now

play01:48

the two out of the four as shown in this

play01:51

in this picture here right requires the

play01:55

help of sagemaker clarify container so

play01:59

in in conclusion you can use sagemaker

play02:03

clarify independent to do a one-off job

play02:05

but you can also use it in conjunction

play02:08

with sagemaker model monitor to run

play02:11

those recurring clarified jobs

play02:18

now in terms of the working process of

play02:20

model monitor we can categorize the

play02:23

model monitoring out of the four into

play02:25

two two different types right one that

play02:28

needs ground truth and one that doesn't

play02:31

need the ground root when I talk about

play02:32

ground truth I'm not talking about the

play02:34

ground truth service that AWS offers but

play02:37

I'm talking more in terms of the actual

play02:39

true labels which are recorded from the

play02:42

business decision that was taken now

play02:44

both data quality drift and feature

play02:47

attribution drift don't really need the

play02:49

ground truth label the monitoring job is

play02:52

scheduled on an interval defined during

play02:54

the scheduling setup and the schedule

play02:57

wakes the model monitor to check budget

play03:00

so the process summary is as follows so

play03:02

step number one is you would create a

play03:04

baseline from the data set that was used

play03:07

to train the model now the Baseline

play03:09

would compute The Matrix and the

play03:11

suggested constraint for The Matrix

play03:14

step number two is you would schedule a

play03:16

monitoring job which captures the data

play03:19

in production and computes the

play03:21

production Matrix

play03:23

and step number three is you would use

play03:25

the model monitor

play03:28

but the way it would do what it would be

play03:31

in the background so what it would do is

play03:33

it will compare the Matrix and send the

play03:36

results or violation report to s Street

play03:38

or cloudwatch

play03:43

now if you look at the other two types

play03:46

which requires the ground truth right it

play03:49

is very similar right the only

play03:51

difference is that both model quality

play03:54

drift and the bias drift requires the

play03:56

ground truth in order to compute the

play03:58

final Matrix now

play04:01

here is additional step as well right

play04:03

you will need to set up another ETL

play04:05

process to bring all the ground root

play04:07

label to S3 adjuring to a specific

play04:10

format as I have highlighted here in

play04:12

this picture and the process follows the

play04:14

same flow so you will first create a

play04:16

baseline from the data set that was used

play04:18

to train the model then you would merge

play04:20

the data capture from the production

play04:22

endpoint with the ground truth label and

play04:25

then the model monitor will actually

play04:27

compare the Matrix and push the result

play04:30

or the violation report to S3 or

play04:33

cloudwatch

play04:37

now in terms of the way it is accessed

play04:40

there are different mechanism let's talk

play04:42

about it in terms of the Persona so AWS

play04:46

python SDK and CLI and sagemaker

play04:49

pipelines are preferred method for

play04:51

machine learning Engineers or data

play04:53

scientists whereas business or data

play04:55

analysts prefers to use the sagemaker UI

play04:57

now there are some limitation while

play05:00

using UI for example if you want to

play05:02

delete the interface endpoint hosted in

play05:04

sagemaker which already has the model

play05:06

monitor enabled you will have first

play05:09

delete the model monitoring schedule via

play05:11

CLI or API and you can't do it on in on

play05:16

the console so I know it kind of gets a

play05:18

little bit tricky and you would get an

play05:19

error as shown in this particular slide

play05:22

so you would have to either use CLI or

play05:24

API to delete it and then from the UI or

play05:27

through API or CLI you can delete it I

play05:29

know it's kind of hard but it is the way

play05:31

it is right now

play05:37

now the model monitor computes model

play05:39

Matrix and statistics on tabular data

play05:42

only for example if you have an image

play05:45

classification model right that takes

play05:47

image it's not tabular data but it's an

play05:48

image as an input and output is a label

play05:51

based on that image that needs you can

play05:55

still use model monitor here but the the

play05:58

key thing to keep in mind is the model

play06:00

monitor will calculate Matrix and

play06:03

statistic for the output and not really

play06:05

the input

play06:06

model monitor currently supports only

play06:09

endpoints that host a single model and

play06:11

does not support monitoring multi-model

play06:14

endpoints not yet right it also supports

play06:17

batch transform

play06:19

so if you have a sequence of different

play06:21

inference and points right leveraging

play06:23

the inference pipeline like a single

play06:25

endpoint but different models in the

play06:27

background you can still use model

play06:29

monitor but the way it would do it it

play06:31

would capture and analyze data for the

play06:33

entire Pipeline and you will not really

play06:35

for the individual containers in the

play06:37

pipeline

play06:38

and if you launch sagemaker studio in a

play06:42

custom Amazon VPC you will need to

play06:44

create a VPC endpoint to enable model

play06:47

monitor to communicate with Amazon S3

play06:50

and cloudwatch

play06:55

now in terms of the data capture

play06:58

the first thing that you have to keep in

play07:00

mind is the AWS region so you want to

play07:02

make sure that the S3 data capture

play07:04

should be in the same region as the

play07:07

model monitor schedule

play07:09

and you want to keep an eye on the

play07:13

inference instance right you want to

play07:15

make sure that the disk utilization is

play07:18

below 75 the reason is to prevent the

play07:22

impact to the inference request the data

play07:24

capture stops capturing requests at a

play07:26

high level of disk utilization and

play07:29

that's why it is recommended that you

play07:31

keep your disk utilization below 75

play07:34

percent in order to ensure data capture

play07:37

continuous capturing request

play07:39

and then if you want that real-time

play07:42

monitoring effect

play07:44

the way you can do it is you want to

play07:46

generate ground truth label quickly and

play07:49

you can leverage Amazon's augmented a to

play07:52

I service to add the human in the loop

play07:55

capability who will generate the the

play07:57

ground truth label and hence you will

play07:59

achieve the real-time monitoring effect

play08:05

now you can customize uh some part of it

play08:10

right some part of the model Monitor and

play08:12

you can Leverage The pre-processing and

play08:15

post processing these are plain python

play08:17

script to transform the input to your

play08:19

model monitor or extend the code after a

play08:22

successful monitoring run you can upload

play08:24

this file to S3 and reference them by

play08:28

create when you're creating your model

play08:29

Monitor and this can be using the create

play08:31

underscore monitoring underscore

play08:32

scheduled method note that it is it will

play08:36

only work

play08:38

with data and model quality jobs so

play08:41

pre-processing can be used for for

play08:44

example data transformation as shown in

play08:46

this particular slide suppose the output

play08:48

of your model is an array but the

play08:51

sagemaker model monitor container really

play08:53

requires tabular or flat and Json

play08:55

structure so you can use the

play08:57

pre-processing script to transform the

play09:00

array into the correct Json structure

play09:02

you can also use it for feature

play09:05

exclusion so suppose your model has an

play09:07

optional feature and you use -1 to

play09:10

denote the optional feature has a

play09:11

missing value if you have a data quality

play09:14

monitor you may want to remove that so

play09:17

that it's not included and doesn't raise

play09:19

any kind of violation right and you can

play09:21

use the preprocessing script to do just

play09:25

that you can remove those values so

play09:27

exclude certain features

play09:29

you can also use it to apply a custom

play09:32

sampling strategy in your pre-processing

play09:34

script for example in this use case it

play09:36

is 10 percent

play09:38

if your pre-processing script returns an

play09:41

error you can check the exception

play09:42

message locked in cloudwatch to debug

play09:44

but in the pre-processing script you can

play09:46

also add additional logging in

play09:50

and then for the post processing Crypt I

play09:52

don't really have an example but other

play09:53

way I would want you to think about is

play09:55

it is when you want to extend the code

play09:58

following a monitoring run so you want

play10:01

to call a business application API or

play10:03

trigger an ETL process or anything that

play10:06

needs to succeed once the monitoring job

play10:09

is completed

play10:19

now let's take let's take a look at the

play10:21

Baseline right so after you have

play10:23

configured your application to capture

play10:25

data during inference the first step to

play10:27

monitor data and model quality or bias

play10:30

or explainability is great Baseline so

play10:32

all the four step has this process in it

play10:34

right now let's take a look at some of

play10:37

the requirements and best practices for

play10:39

different Baseline so if you're using it

play10:42

for data quality the data quality

play10:44

Baseline let's take a look at that first

play10:45

scenario the schema of the training data

play10:48

set Baseline data set and inference data

play10:51

set should be the same

play10:52

both the number and the Order of the

play10:55

feature the First Column should refer to

play10:58

the prediction or output an important

play11:01

point to note here for avoiding error is

play11:04

to ensure that the column names for the

play11:06

Baseline data set has only lowered case

play11:09

letters and underscore as the only

play11:12

separator now this is to maintain the

play11:15

maximum compatibility between Spa CSV

play11:18

Json and parquet special characters can

play11:21

cause issues too so be careful there as

play11:23

well now in model quality monitoring the

play11:27

predictions are compared to the ground

play11:28

truth label hence a model quality

play11:31

Baseline needs access to a data set that

play11:35

contains the ground truth label and

play11:37

prediction from the model being

play11:38

monitored

play11:40

now for feature attribution drift

play11:43

the way it is measured is by using the

play11:45

kernel snap algorithm one needs to make

play11:48

a trade-off between the time taken and

play11:51

the complexity of the surrogate model by

play11:54

using the number of samples parameter

play11:56

above all the main thing is to provide a

play12:00

good Baseline for your users typically

play12:02

training data validation data or a

play12:06

golden batch data

play12:10

okay now let's take a look at the bias

play12:13

drift Baseline right you can specify it

play12:17

when you specify the configuration bias

play12:19

config and you have the label value or

play12:22

threshold to indicate the positive

play12:24

outcome the facet name to specify the

play12:27

sensitive attribute column or the

play12:29

feature column and the facet value or

play12:31

threshold to specify the value in that

play12:33

particular attribute

play12:35

now let's take take a look at the second

play12:37

example here right so the facet theme is

play12:39

petal petal length The Petal length of

play12:42

the flower and the facet threshold that

play12:45

you have is set to five

play12:51

now the suggest underscore Baseline

play12:54

method of the model monitor or model

play12:57

quality monitor classes triggers a

play12:59

processing job that computes the Matrix

play13:01

and constraint for the Baseline now the

play13:04

result of the Baseline job are two files

play13:06

like we mentioned in the previous slide

play13:08

statistic.json and constraint.json now

play13:11

you can review the generated constraint

play13:13

and modify them before using them for

play13:15

monitoring based on your understanding

play13:18

of the domain and the business problem

play13:19

you can actually make constrained more

play13:21

aggressive or relax it to control the

play13:24

number and the nature of the violation

play13:26

or like in the given example you can add

play13:29

a field to define a string constraint

play13:31

based on the understanding of your data

play13:34

as a best practice always review the

play13:38

Baseline constraint generated by model

play13:40

Monitor and adapt it as per your use

play13:42

case

play13:45

now to schedule monitoring for real-time

play13:47

endpoints you would use a create

play13:49

underscore monitoring underscore

play13:50

schedule method of the respective model

play13:52

monitor class now when the ground truth

play13:55

is required for monitoring jobs like

play13:58

model quality you will need to ensure

play14:00

that a monitoring job only uses data for

play14:04

which the crown truth is available you

play14:07

can also want to keep an eye on the

play14:11

start time offset and end time offset to

play14:14

select the data that you want to use so

play14:17

in quick example of the first use first

play14:19

example here right if your ground truth

play14:22

comes in three days after the prediction

play14:24

has been made you would want to set the

play14:26

start time offset to p3d and end time

play14:30

offset to minus P 1 D which is three

play14:34

days and one day respectively

play14:37

now if your ground truth arrives six

play14:39

hours after the prediction and you have

play14:42

an hourly schedule then you would use

play14:44

the six hours and one hour in that

play14:46

offset now you can schedule model

play14:49

monitoring job for both a real-time

play14:52

endpoint and a batch transform like we

play14:55

talked in the previous slide

play14:58

you also have an option to run these job

play15:01

on demand doesn't have to be scheduled

play15:03

all the time and the way you can do it

play15:05

is by leveraging sagemaker pipeline

play15:08

which is a fully managed ml Ops service

play15:11

that siegemaker offers is completely

play15:13

free of charge to use but until you will

play15:16

only end up paying for the underlying

play15:17

compute so it's serverless in that

play15:19

manner

play15:21

and the way you can do that set up your

play15:24

on-demand monitoring job is by

play15:26

leveraging the these two methods so

play15:29

check

play15:30

job config and then you would specify

play15:33

the quality check config and then for

play15:36

the clarify one for checking the bias

play15:39

and explainability you can leverage your

play15:41

clarify check config

play15:46

now sagemaker do offer a lot of

play15:50

pre-built algorithms and containers but

play15:53

if you have a use case wherein you have

play15:55

to have to bring your own container then

play15:58

that should not stop you from leveraging

play16:00

model monitor sagemaker model monitor to

play16:03

provide a pre-bill container with the

play16:04

ability to analyze the data captured

play16:06

from endpoint or batch transform job for

play16:08

tabular data set

play16:10

but if you are bringing in your own

play16:12

container you would it provides you

play16:14

extension points which you can leverage

play16:16

basically you have to adhere to the

play16:19

contract input and contract output to

play16:21

leverage the model monitor the container

play16:24

can analyze the data in the data set

play16:27

underscore Source path and write the

play16:30

report to the path in the output

play16:32

underscore path the container code can

play16:34

write any report that suits your name if

play16:37

you use the following structure and

play16:39

contract certain output files are

play16:41

treated specifically by sagemaker in the

play16:43

visualization and API

play16:46

some scenarios where this can be useful

play16:49

is when you want to design monitoring

play16:52

for computer vision or natural language

play16:54

use cases or design any kind of custom

play16:56

metrics you can go ahead and leverage

play16:58

this mechanism

play17:02

now you have all this data and you you

play17:05

know you're getting alerted as well but

play17:07

what do the data is good only when you

play17:10

to take it take that data to do certain

play17:14

action and if you automate the action

play17:17

then that's the most beautiful part

play17:19

about it right so having a effective

play17:23

deployment you know and model monitoring

play17:25

phase is important right and you want to

play17:29

continuously keep an eye on what's

play17:31

really happening

play17:32

in this example it's just one of the

play17:35

sample architecture and I will link the

play17:37

blog post in the description of this

play17:39

particular video

play17:40

what it does is it will detect a drift

play17:43

in data drift for the model which was

play17:46

deployed right with respect to what was

play17:49

the trading Baseline

play17:50

and once that drift is detected and the

play17:54

Matrix exceeds the model specific

play17:56

threshold

play17:57

then a cloud watch alarm is triggered

play17:59

and an event Bridge rule will start the

play18:03

model Bill pipeline that means it will

play18:05

trigger the retraining and hence in this

play18:08

way you can have the model retraining be

play18:10

automated based on the violation raised

play18:13

by the model monitoring

play18:15

so that's it from my side I mean the

play18:18

idea here is for us to leverage the best

play18:21

practices while you're using Sage picker

play18:23

model monitor it's really a powerful

play18:25

tool and it's fully managed so you know

play18:27

go ahead and use it and let me know what

play18:29

you think

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
SageMakerModel MonitoringData QualityModel QualityBias ReportExplainabilityMachine LearningData ScienceMonitoring ToolsAWS Services
¿Necesitas un resumen en inglés?