Skip to content

Commit bf6739d

Browse files
committed
Edit content
1 parent 5101528 commit bf6739d

File tree

1 file changed

+50
-30
lines changed

1 file changed

+50
-30
lines changed

articles/machine-learning/how-to-monitor-model-performance.md

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ To set up out-of-box model monitoring, use code that's similar to the following
107107
| <workspace_name> | The name of your workspace | my-workspace |
108108
| <endpoint-name> | The name of the endpoint to monitor | credit-default |
109109
| <deployment-name> | The name of the deployment to monitor | main |
110-
| <email-address1> and <email-address2> | Email addresses to use for notifications | `[email protected]` |
110+
| <email-address-1> and <email-address-2> | Email addresses to use for notifications | `[email protected]` |
111111
| <frequency-unit> | The monitoring frequency unit, such as "minute," "hour," "day," "week," or "month" | day |
112112
| <interval> | The interval between jobs, such as 1 or 2 days or weeks | 1 |
113113
| <start-hour> | The hour to start monitoring, on a 24-hour clock | 3 |
@@ -148,7 +148,7 @@ monitoring_target = MonitoringTarget(
148148

149149
# Create an alert notification object.
150150
alert_notification = AlertNotification(
151-
emails=['<email-address1>', '<email-address2>']
151+
emails=['<email-address-1>', '<email-address-2>']
152152
)
153153

154154
# Create the monitor definition.
@@ -260,7 +260,7 @@ To set up advanced model monitoring, use code that's similar to the following sa
260260
| <reference-data-asset-name> | The name of the data asset that contains reference data | credit-default-reference |
261261
| <target-column> | The name of the output column that contains values that the model predicts | DEFAULT_NEXT_MONTH |
262262
| <feature1>, <feature2>, and <feature3> | The features that you want to use in an advanced data quality signal | AGE |
263-
| <email-address1> and <email-address2> | Email addresses to use for notifications | `[email protected]` |
263+
| <email-address-1> and <email-address-2> | Email addresses to use for notifications | `[email protected]` |
264264
| <frequency-unit> | The monitoring frequency unit, such as "minute," "hour," "day," "week," or "month" | day |
265265
| <interval> | The interval between jobs, such as 1 or 2 days or weeks | 1 |
266266
| <start-hour> | The hour to start monitoring, on a 24-hour clock | 3 |
@@ -410,7 +410,7 @@ monitoring_signals = {
410410

411411
# Create an alert notification object.
412412
alert_notification = AlertNotification(
413-
emails=['<email-address1>', '<email-address2>']
413+
emails=['<email-address-1>', '<email-address-2>']
414414
)
415415

416416
# Create the monitor definition.
@@ -636,7 +636,7 @@ After you satisfy the [prerequisites for model performance monitoring](#more-pre
636636
| <ground-truth-data-asset-name> | The name of the data asset that contains ground truth data | credit-ground-truth |
637637
| <ground-truth-target-column> | The name of the ground truth column that contains actual data that the model tries to predict | ground_truth|
638638
| <ground-truth-join-column> | The name of the ground truth column to use to join the production and ground truth data | correlationid |
639-
| <email-address1> and <email-address2> | Email addresses to use for notifications | `[email protected]` |
639+
| <email-address-1> and <email-address-2> | Email addresses to use for notifications | `[email protected]` |
640640
| <frequency-unit> | The monitoring frequency unit, such as "minute," "hour," "day," "week," or "month" | day |
641641
| <interval> | The interval between jobs, such as 1 or 2 days or weeks | 1 |
642642
| <start-hour> | The hour to start monitoring, on a 24-hour clock | 3 |
@@ -699,7 +699,7 @@ production_data = ProductionData(
699699
)
700700
)
701701
702-
# Specify ground truth reference data.
702+
# Specify the ground truth reference data.
703703
reference_data_ground_truth = ReferenceData(
704704
input_data=Input(
705705
type="mltable",
@@ -734,7 +734,7 @@ monitoring_signals = {
734734
735735
# Create an alert notification object.
736736
alert_notification = AlertNotification(
737-
emails=['<email-address1>', '<email-address2>']
737+
emails=['<email-address-1>', '<email-address-2>']
738738
)
739739
740740
# Set up the monitor definition.
@@ -848,15 +848,30 @@ After you register your production data and preprocessing component, you can set
848848

849849
:::code language="yaml" source="~/azureml-examples-main/cli/monitoring/model-monitoring-with-collected-data.yaml":::
850850

851-
1. Run the following command to create the model:
852-
851+
1. Run the following command to create the model. Replace `<file-name>` with the name of the model specification file, such as `model-monitoring-with-collected-data.yaml`.
853852

854853
```azurecli
855-
az ml schedule create -f ./model-monitoring-with-collected-data.yaml
854+
az ml schedule create -f ./<file-name>
856855
```
857856

858857
# [Python SDK](#tab/python)
859858

859+
Use a script that's similat to the following Python code to set up model monitoring. First replace the following placeholders with appropriate values:
860+
861+
| Placeholder | Description | Example |
862+
| --- | --- | --- |
863+
| <subscription_ID> | The ID of your subscription | aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e |
864+
| <resource-group-name> | The name of the resource group that contains your workspace | my-resource-group |
865+
| <workspace_name> | The name of your workspace | my-workspace |
866+
| <production-data-asset-name> | The name of the data asset that contains production data | my_model_production_data |
867+
| <preprocessing-component-name> | The name of your preprocessing component | production_data_preprocessing |
868+
| <training-data-asset-name> | The name of the training data asset that you want to use as a reference data asset | my_model_training_data |
869+
| <email-address-1> and <email-address-2> | Email addresses to use for notifications | `[email protected]` |
870+
| <frequency-unit> | The monitoring frequency unit, such as "minute," "hour," "day," "week," or "month" | day |
871+
| <interval> | The interval between jobs, such as 1 or 2 days or weeks | 1 |
872+
| <start-hour> | The hour to start monitoring, on a 24-hour clock | 3 |
873+
| <start-minutes> | The minutes after the specified hour to start monitoring | 15 |
874+
860875
```python
861876
from azure.identity import InteractiveBrowserCredential
862877
from azure.ai.ml import Input, MLClient
@@ -887,40 +902,43 @@ from azure.ai.ml.entities import (
887902
ProductionData
888903
)
889904
890-
# get a handle to the workspace
905+
# Get a handle to the workspace.
906+
subscription_id = "<subscription-ID>"
907+
resource_group = "<resource-group-name>"
908+
workspace = "<workspace-name>"
891909
ml_client = MLClient(
892910
InteractiveBrowserCredential(),
893911
subscription_id,
894912
resource_group,
895913
workspace
896914
)
897915
916+
# Specify the compute instance.
898917
spark_compute = ServerlessSparkCompute(
899918
instance_type="standard_e4s_v3",
900-
runtime_version="3.2"
919+
runtime_version="3.3"
901920
)
902921
903-
#define target dataset (production dataset)
922+
# Specify the target data asset (the production data asset).
904923
production_data = ProductionData(
905924
input_data=Input(
906925
type="uri_folder",
907-
path="azureml:my_model_production_data:1"
926+
path="azureml:<production-data-asset-name>:1"
908927
),
909928
data_context=MonitorDatasetContext.MODEL_INPUTS,
910-
pre_processing_component="azureml:production_data_preprocessing:1"
929+
pre_processing_component="azureml:<preprocessing-component-name>:1.0.0"
911930
)
912931
913-
914-
# training data to be used as reference dataset
932+
# Specify the training data to use as a reference data asset.
915933
reference_data_training = ReferenceData(
916934
input_data=Input(
917935
type="mltable",
918-
path="azureml:my_model_training_data:1"
936+
path="azureml:<training-data-asset-name>:1"
919937
),
920938
data_context=MonitorDatasetContext.TRAINING
921939
)
922940
923-
# create an advanced data drift signal
941+
# Create an advanced data drift signal.
924942
features = MonitorFeatureFilter(top_n_feature_importance=20)
925943
metric_thresholds = DataDriftMetricThreshold(
926944
numerical=NumericalDriftMetrics(
@@ -938,8 +956,7 @@ advanced_data_drift = DataDriftSignal(
938956
metric_thresholds=metric_thresholds
939957
)
940958
941-
942-
# create an advanced data quality signal
959+
# Create an advanced data quality signal.
943960
features = ['feature_A', 'feature_B', 'feature_C']
944961
metric_thresholds = DataQualityMetricThreshold(
945962
numerical=DataQualityMetricsNumerical(
@@ -958,46 +975,49 @@ advanced_data_quality = DataQualitySignal(
958975
alert_enabled="False"
959976
)
960977
961-
# put all monitoring signals in a dictionary
978+
# Put all monitoring signals in a dictionary.
962979
monitoring_signals = {
963980
'data_drift_advanced': advanced_data_drift,
964981
'data_quality_advanced': advanced_data_quality
965982
}
966983
967-
# create alert notification object
984+
# Create an alert notification object.
968985
alert_notification = AlertNotification(
969-
986+
emails=['<email-address-1>', '<email-address-2>']
970987
)
971988
972-
# Finally monitor definition
989+
# Set up the monitor definition.
973990
monitor_definition = MonitorDefinition(
974991
compute=spark_compute,
975992
monitoring_signals=monitoring_signals,
976993
alert_notification=alert_notification
977994
)
978995
996+
# Specify the schedule frequency.
979997
recurrence_trigger = RecurrenceTrigger(
980-
frequency="day",
981-
interval=1,
982-
schedule=RecurrencePattern(hours=3, minutes=15)
998+
frequency="<frequency-unit>",
999+
interval=<interval>,
1000+
schedule=RecurrencePattern(hours=<start-hour>, minutes=<start-minutes>)
9831001
)
9841002
1003+
# Create the monitoring schedule.
9851004
model_monitor = MonitorSchedule(
9861005
name="fraud_detection_model_monitoring_advanced",
9871006
trigger=recurrence_trigger,
9881007
create_monitor=monitor_definition
9891008
)
9901009
1010+
# Schedule the monitoring job.
9911011
poller = ml_client.schedules.begin_create_or_update(model_monitor)
9921012
created_monitor = poller.result()
9931013
9941014
```
9951015

9961016
# [Studio](#tab/azure-studio)
9971017

998-
The studio currently doesn't support configuring monitoring for models that are deployed outside of Azure Machine Learning. See the Azure CLI or Python SDK tabs instead.
1018+
The studio currently doesn't support configuring monitoring for models that are deployed outside Azure Machine Learning. See the Azure CLI or Python SDK tabs instead.
9991019

1000-
Once you've configured your monitor with the CLI or SDK, you can view the monitoring results in the studio. For more information on interpreting monitoring results, see [Interpreting monitoring results](how-to-monitor-model-performance.md#interpret-monitoring-results).
1020+
After you use the Azure CLI or the Python SDK to configure monitoring, you can view the monitoring results in the studio. For more information about interpreting monitoring results, see [Interpret monitoring results](how-to-monitor-model-performance.md#interpret-monitoring-results).
10011021

10021022
---
10031023

0 commit comments

Comments
 (0)