

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

# 生產中模型的偏差偏離
<a name="clarify-model-monitor-bias-drift"></a>

Amazon SageMaker Clarify 偏差監控可協助資料科學家和機器學習 (ML) 工程師定期監控偏差的預測。當模型受到監控時，客戶可以在 SageMaker Studio 中檢視可匯出的報告和圖表以了解偏差詳細資料，並在 Amazon CloudWatch 中設定警示以便在偵測到超出特定閾值的偏差時接收通知。當訓練資料與部署期間模型所看到的資料 (也就是即時資料) 不同時，可能會在部署的機器學習 (ML) 模型中導致或加劇偏差。即時資料分佈中這些類型的變更可能是暫時性的 (例如，由於某些短暫、真實世界的事件)或永久性的。無論哪種情況，偵測這些變更都很重要。例如，如果用於訓練模型的抵押貸款利率與目前真實世界的抵押貸款利率不同，則用於預測房屋價格的模型輸出可能會變得偏差。透過 Model Monitor 中的偏差偵測功能，當 SageMaker AI 偵測到超過特定閾值的偏差時，會自動產生您在 SageMaker Studio 中以及透過 Amazon CloudWatch 警示可以檢視的指標。

一般而言，僅在訓練和部署階段測量偏差可能不足。部署模型之後，部署模型所看到的資料分佈 (也就是即時資料) 可能與訓練資料集中的資料分佈不同。在一段時間後，此變更可能會導致模型中的偏差。即時資料分佈的變更可能是暫時的 (例如，由於某些短暫的行為，如假期節日) 或永久性的。無論哪種情況，偵測這些變更並在適當時採取措施以減少偏差很重要。

為了偵測這些變更，SageMaker Clarify 提供持續監控已部署模型的偏差指標的功能，並在指標超過閾值時提出自動警示。例如，考量 DPPL 偏差指標。指定允許的值範圍 A=(amin​,amax​)，例如 DPPL 在部署期間應屬於的間隔 (-0.1, 0.1)。此範圍之間的任何偏差都應提出*偵測到偏差*的警示。使用 SageMaker Clarify，您可以定期執行這些檢查。

例如，您可以將檢查頻率設為 2 天。這表示 SageMaker Clarify 會根據 2 天期間內收集的資料來計算 DPPL 指標。在此範例中，Dwin 是模型在過去 2 天期間內處理的資料。如果在 Dwin​ 上計算的 DPPL 值 bwin​ 超出允許的範圍 A，則會發出警示。檢查 bwin 是否超出 A 的這種方法可能會有些嘈雜。Dwin​ 可能由極少數樣本組成，並且可能不代表即時資料分佈。小型樣本意味著在 Dwin​ 上計算的偏差 bwin​ 值可能不是非常強大的估計值。事實上，非常高 (或低) 的 bwin 值可能純粹是由於機會而觀察到的。為了確保從觀察到的資料 Dwin 得出的結論在統計上具有顯著性，SageMaker Clarify 使用信賴區間。具體而言，它會使用一般引導區間方法來建構區間 C=(cmin​,cmax​)，如此 SageMaker Clarify 可確信透過完整即時資料計算的真正偏差值會以高可能性包含在 C 中。現在，如果信賴區間 C 與允許的範圍 A 重疊，SageMaker Clarify 會將其解譯為 “即時資料分佈的偏差指標值很可能落在允許的範圍內”。如果 C 和 A 是脫離的，則 SageMaker Clarify 可確信偏差指標不在 A 中並提出警示。

## 模型監控取樣筆記本
<a name="clarify-model-monitor-sample-notebooks-bias-drift"></a>

Amazon SageMaker Clarify 提供下列取樣筆記本，其中顯示如何擷取即時端點的推論資料、建立基準以監控不斷發展的偏差，以及檢查結果：
+ [監控偏差偏離和功能屬性偏離 Amazon SageMaker Clarify](https://sagemaker-examples.readthedocs.io/en/latest/sagemaker_model_monitor/fairness_and_explainability/SageMaker-Model-Monitor-Fairness-and-Explainability.html) – 使用 Amazon SageMaker Model Monitor 來監控一段時間後的偏差偏離和功能屬性偏離。

此筆記本已通過驗證，只能在 Amazon SageMaker Studio 中執行。如果您需要有關如何在 Amazon SageMaker Studio 中打開筆記本的說明，請參閱[建立或開啟 Amazon SageMaker Studio Classic 筆記本](notebooks-create-open.md)。如果系統提示您選擇核心，請選擇 **Python 3 (資料科學)**。下列主題包含最後兩個步驟的重點內容，其中包含範例筆記本的程式碼範例。

**Topics**
+ [模型監控取樣筆記本](#clarify-model-monitor-sample-notebooks-bias-drift)
+ [建立偏差偏離基準](clarify-model-monitor-bias-drift-baseline.md)
+ [偏差偏離違規](clarify-model-monitor-bias-drift-violations.md)
+ [要監控偏差偏離的參數](clarify-config-json-monitor-bias-parameters.md)
+ [排定偏差偏離監控工作](clarify-model-monitor-bias-drift-schedule.md)
+ [檢查報告中的資料偏差偏離](clarify-model-monitor-bias-drift-report.md)
+ [偏差偏離分析的 CloudWatch 指標](clarify-model-monitor-bias-drift-cw.md)

# 建立偏差偏離基準
<a name="clarify-model-monitor-bias-drift-baseline"></a>

將應用程式設定為擷取即時或批次轉換推論資料之後，監控偏差偏離的第一項任務是建立基準。這包括設定資料輸入、哪些群組是敏感的、如何擷取預測，以及模型及其訓練後的偏差指標。然後，您需要開始進行基準工作。

模型偏差監控可定期偵測機器學習 (ML) 模型的偏差偏離。與其他監控類型相似，建立模型偏差監控的標準程序首先是基準化，然後再建立監控排程。

```
model_bias_monitor = ModelBiasMonitor(
    role=role,
    sagemaker_session=sagemaker_session,
    max_runtime_in_seconds=1800,
)
```

`DataConfig` 會儲存要分析之資料集的相關資訊 (例如，資料集檔案)、其格式 (亦即 CSV 或 JSON 行)、標題 (如果有的話) 和標籤。

```
model_bias_baselining_job_result_uri = f"{baseline_results_uri}/model_bias"
model_bias_data_config = DataConfig(
    s3_data_input_path=validation_dataset,
    s3_output_path=model_bias_baselining_job_result_uri,
    label=label_header,
    headers=all_headers,
    dataset_type=dataset_type,
)
```

`BiasConfig` 是資料集中敏感群組的組態。一般而言，偏差是透過計算指標並跨群組進行比較來衡量。感興趣的群組稱為*構面*。對於訓練後的偏差，您還應該考慮正面的標籤。

```
model_bias_config = BiasConfig(
    label_values_or_threshold=[1],
    facet_name="Account Length",
    facet_values_or_threshold=[100],
)
```

`ModelPredictedLabelConfig` 會指定如何從模型輸出擷取預測標籤。在此範例中，選擇 0.8 截止值是為了預期客戶會經常流動。對於更複雜的輸出，還有幾個選項，例如 “label” 是索引、名稱或 JMESPath，以在端點回應承載中定位預測標籤。

```
model_predicted_label_config = ModelPredictedLabelConfig(
    probability_threshold=0.8,
)
```

`ModelConfig` 是與要用於推論的模型相關的組態。為了計算訓練後的偏差指標，計算需要取得所提供的模型名稱的推論。為了完成此作業，處理任務會使用模型來建立暫時性端點 (也稱為*陰影端點*)。處理任務會在計算完成後刪除陰影端點。可解釋性監控也會使用此組態。

```
model_config = ModelConfig(
    model_name=model_name,
    instance_count=endpoint_instance_count,
    instance_type=endpoint_instance_type,
    content_type=dataset_type,
    accept_type=dataset_type,
)
```

現在，您可以開始基準工作。

```
model_bias_monitor.suggest_baseline(
    model_config=model_config,
    data_config=model_bias_data_config,
    bias_config=model_bias_config,
    model_predicted_label_config=model_predicted_label_config,
)
print(f"ModelBiasMonitor baselining job: {model_bias_monitor.latest_baselining_job_name}")
```

排程的監控會自動挑選基準作業名稱，並等待它，然後再開始監控。

# 偏差偏離違規
<a name="clarify-model-monitor-bias-drift-violations"></a>

偏差偏離工作會根據目前 `MonitoringExecution` 的分析結果，評估[基準組態](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModelBiasJobDefinition.html#sagemaker-CreateModelBiasJobDefinition-request-ModelBiasBaselineConfig)提供的基準限制條件。如果偵測到違規，工作會將其列於執行輸出位置中的 *constraint\$1violations.json* 檔案，並將執行狀態標記為 [解讀結果](model-monitor-interpreting-results.md)。

以下是偏差偏離違規檔案的結構描述。
+ `facet` – 構面的名稱，由監控工作分析組態構面 `name_or_index` 提供。
+ `facet_value` – 構面的值，由監控工作分析組態構面 `value_or_threshold` 提供。
+ `metric_name` – 偏差指標的簡短名稱。例如，“CI” 表示類別不平衡。如需每個訓練前偏差指標的簡短名稱，請參閱[訓練前偏差指標](clarify-measure-data-bias.md)，如需每個訓練後偏差指標的簡短名稱，請參閱[訓練後資料和模型偏差指標](clarify-measure-post-training-bias.md)。
+ `constraint_check_type` – 監控的違規類型。目前僅支援 `bias_drift_check`。
+ `description` – 說明違規的描述訊息。

```
{
    "version": "1.0",
    "violations": [{
        "facet": "string",
        "facet_value": "string",
        "metric_name": "string",
        "constraint_check_type": "string",
        "description": "string"
    }]
}
```

偏差指標用於測量分佈中的相等程度。接近零的值表示分佈較為平衡。如果工作分析結果檔案 (analysis.json) 中偏差指標的值低於其在基準限制檔案中的對應值，則會記錄違規。例如，如果 DPPL 偏差指標的基準限制條件為 `0.2`，且分析結果為 `0.1`，則不會記錄違規，因為 `0.1` 比 `0.2` 更接近 `0`。但是，如果分析結果為 `-0.3`，則會記錄違規，因為比 `0.2` 的基準限制條件更遠於 `0`。

```
{
    "version": "1.0",
    "violations": [{
        "facet": "Age",
        "facet_value": "40",
        "metric_name": "CI",
        "constraint_check_type": "bias_drift_check",
        "description": "Value 0.0751544567666083 does not meet the constraint requirement"
    }, {
        "facet": "Age",
        "facet_value": "40",
        "metric_name": "DPPL",
        "constraint_check_type": "bias_drift_check",
        "description": "Value -0.0791244970125596 does not meet the constraint requirement"
    }]
}
```

# 要監控偏差偏離的參數
<a name="clarify-config-json-monitor-bias-parameters"></a>

Amazon SageMaker Clarify 偏差監控會重複使用 [分析組態檔案](clarify-processing-job-configure-analysis.md) 的分析組態中使用的參數子集。說明組態參數之後，本主題將提供 JSON 檔案的範例。這些檔案可用來設定 CSV 和 JSON 行資料集，在機器學習模型進行生產時監控是否有偏差偏離。

JSON 檔案必須提供下列參數。此 JSON 檔案的路徑必須在 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ModelBiasAppSpecification](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ModelBiasAppSpecification) API 的 `ConfigUri` 參數中提供。
+ `"version"` –(選用) 組態檔案的結構描述版本。如果未提供，則會使用最新的支援版本。
+ `"headers"` –(選用) 資料集中的欄位名稱清單。如果 `dataset_type` 為 `"label"` 並已指定 `"application/jsonlines"`，則最後一個標題將成為標籤欄的標題。
+ `"label"` –(選用) 要用於*偏差指標*之模型的目標屬性。指定為資料欄名稱或索引 (如果資料集格式為 CSV)，或指定為 JMESPath( 如果資料集格式為 JSON 行)。
+ `"label_values_or_threshold"` –(選用) 標籤值或閾值的清單。表示用於偏差指標的正面結果。
+ `"facet"` –(選用) 屬於敏感屬性的功能清單，稱為構面。構面以配對形式用於*偏差指標*，並包括以下內容：
  + `"name_or_index"` – 構面欄名稱或索引。
  + `"value_or_threshold"` –(選用) 構面欄可採用的值或閾值清單。表示敏感群組，例如用來測量偏差的群組。如果未提供，偏差指標會將每個唯一值 (而非所有值) 計算為一個群組。如果構面欄為數值，則會套用此閾值為下限以選取敏感群組。
+ `"group_variable"` – (選用) 欄名稱或索引，用來指出要用於*偏差指標**條件人口統計差異*的群組變數。

其他參數應在 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ModelBiasJobInput](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ModelBiasJobInput) API 的 `EndpointInput` (用於即時端點) 或 `BatchTransformInput` (用於批次轉換工作) 中提供。
+ `FeaturesAttribute` – 如果端點輸入資料格式為 `"application/jsonlines"`，則此參數是必要項目。如果資料集格式是 JSON 行，它是用於定位功能欄的 JMESPath。
+ `InferenceAttribute` – 目標屬性的模型輸出中的索引或 JMESPath 位置，用於使用偏差指標來監控偏差。如果在 CSV `accept_type` 案例中未提供，則假設模型輸出是對應於分數或機率的單一數值。
+ `ProbabilityAttribute` – 機率的模型輸出中的索引或 JMESPath 位置。例如，如果模型輸出是含有標籤和機率清單的 JSON 行，則會選擇對應於最大機率的標籤進行偏差運算。
+ `ProbabilityThresholdAttribute` –(選用) 浮點值，用來指示在二進制分類的情況下選取二進位標籤的閾值。預設值為 0.5。

## CSV 和 JSON 行資料集的 JSON 組態檔案範例
<a name="clarify-config-json-monitor-bias-parameters-examples"></a>

以下是 JSON 檔案的範例，用來設定 CSV 和 JSON 行資料集以監控偏差偏離。

**Topics**
+ [CSV 資料集](#clarify-config-json-monitor-bias-parameters-example-csv)
+ [JSON 行資料集](#clarify-config-json-monitor-bias-parameters-example-jsonlines)

### CSV 資料集
<a name="clarify-config-json-monitor-bias-parameters-example-csv"></a>

考慮有四個功能欄和一個標籤欄的資料集，其中第一個功能和標籤是二進位，如下列範例所示。

```
0, 0.5814568701544718, 0.6651538910132964, 0.3138080342665499, 0
1, 0.6711642728531724, 0.7466687034026017, 0.1215477472819713, 1
0, 0.0453256543003371, 0.6377430803264152, 0.3558625219713576, 1
1, 0.4785191813363956, 0.0265841045263860, 0.0376935084990697, 1
```

假設模型輸出有兩欄，其中第一個是預測標籤，第二個是機率，如下列範例所示。

```
1, 0.5385257417814224
```

接著，下列 JSON 組態檔案會顯示如何設定此 CSV 資料集的範例。

```
{
    "headers": [
        "feature_0",
        "feature_1",
        "feature_2",
        "feature_3",
        "target"
    ],
    "label": "target",
    "label_values_or_threshold": [1],
    "facet": [{
        "name_or_index": "feature_1",
        "value_or_threshold": [1]
    }]
}
```

預測標籤由 `"InferenceAttribute"` 參數選取。使用從零開始的編號，因此 0 表示模型輸出的首欄，

```
"EndpointInput": {
    ...
    "InferenceAttribute": 0
    ...
}
```

或者，您可以使用不同的參數將機率值轉換為二進位預測標籤。使用從零開始的編號：1 表示第二欄；`ProbabilityThresholdAttribute` 值 0.6 表示大於 0.6 的機率會將二進位標籤預測為 1。

```
"EndpointInput": {
    ...
    "ProbabilityAttribute": 1,
    "ProbabilityThresholdAttribute": 0.6
    ...
}
```

### JSON 行資料集
<a name="clarify-config-json-monitor-bias-parameters-example-jsonlines"></a>

考慮有四個功能欄和一個標籤欄的資料集，其中第一個功能和標籤是二進位，如下列範例所示。

```
{"features":[0, 0.5814568701544718, 0.6651538910132964, 0.3138080342665499], "label":0}
{"features":[1, 0.6711642728531724, 0.7466687034026017, 0.1215477472819713], "label":1}
{"features":[0, 0.0453256543003371, 0.6377430803264152, 0.3558625219713576], "label":1}
{"features":[1, 0.4785191813363956, 0.0265841045263860, 0.0376935084990697], "label":1}
```

假設模型輸出有兩欄，其中第一個是預測標籤，第二個是機率。

```
{"predicted_label":1, "probability":0.5385257417814224}
```

下列 JSON 組態檔案會顯示如何設定此 JSON 行資料集的範例。

```
{
    "headers": [
        "feature_0",
        "feature_1",
        "feature_2",
        "feature_3",
        "target"
    ],
    "label": "label",
    "label_values_or_threshold": [1],
    "facet": [{
        "name_or_index": "feature_1",
        "value_or_threshold": [1]
    }]
}
```

然後，`EndpointInput` 中的 `"features"` 參數值 (針對即時端點) 或 `BatchTransformInput` (針對批次轉換工作) 用於訂位資料集中的功能，而 `"predicted_label"` 參數值會從模型輸出中選取預測標籤。

```
"EndpointInput": {
    ...
    "FeaturesAttribute": "features",
    "InferenceAttribute": "predicted_label"
    ...
}
```

或者，您可以使用 `ProbabilityThresholdAttribute` 參數值將機率值轉換為預測的二進位標籤。例如，0.6 的值表示大於 0.6 的的機率會預測二進位標籤為 1。

```
"EndpointInput": {
    ...
    "FeaturesAttribute": "features",
    "ProbabilityAttribute": "probability",
    "ProbabilityThresholdAttribute": 0.6
    ...
}
```

# 排定偏差偏離監控工作
<a name="clarify-model-monitor-bias-drift-schedule"></a>

建立基準之後，您可以呼叫 `ModelBiasModelMonitor` 類別執行個體的 `create_monitoring_schedule()` 方法來排程每小時的偏差偏離監控。以下各節說明如何為部署到即時端點的模型以及批次轉換工作建立偏差偏離監控。

**重要**  
在建立監控排程時，您可以指定批次轉換輸入或端點輸入，但不能同時指定兩者。

與資料品質監控不同，如果要監控模型品質，需要提供 Ground Truth 標籤。但是，Ground Truth 標籤可能會延遲。若要解決此問題，請在建立監控排程時指定偏移。如需有關如何建立時間位移的詳細資訊，請參閱[模型監控偏移](model-monitor-model-quality-schedule.md#model-monitor-model-quality-schedule-offsets)。

如果您已提交基準工作，監控會自動從基準工作中挑選分析組態。如果您略過基準步驟，或擷取資料集的性質與訓練資料集的性質不同，則必須提供分析組態。

## 部署至即時端點的模型的偏差偏離監控
<a name="model-monitor-bias-quality-rt"></a>

若要為即時端點排程偏差偏離監控，請將 `EndpointInput` 執行個體傳遞至 `ModelBiasModelMonitor` 執行個體的 `endpoint_input` 引數，如下列程式碼範例所示：

```
from sagemaker.model_monitor import CronExpressionGenerator
            
model_bias_monitor = ModelBiasModelMonitor(
    role=sagemaker.get_execution_role(),
    ...
)

model_bias_analysis_config = None
if not model_bias_monitor.latest_baselining_job:
    model_bias_analysis_config = BiasAnalysisConfig(
        model_bias_config,
        headers=all_headers,
        label=label_header,
    )

model_bias_monitor.create_monitoring_schedule(
    monitor_schedule_name=schedule_name,
    post_analytics_processor_script=s3_code_postprocessor_uri,
    output_s3_uri=s3_report_path,
    statistics=model_bias_monitor.baseline_statistics(),
    constraints=model_bias_monitor.suggested_constraints(),
    schedule_cron_expression=CronExpressionGenerator.hourly(),
    enable_cloudwatch_metrics=True,
    analysis_config=model_bias_analysis_config,
    endpoint_input=EndpointInput(
        endpoint_name=endpoint_name,
        destination="/opt/ml/processing/input/endpoint",
        start_time_offset="-PT1H",
        end_time_offset="-PT0H",
        probability_threshold_attribute=0.8,
    ),
)
```

## 批次轉換工作的偏差偏離監控
<a name="model-monitor-bias-quality-bt"></a>

若要為批次轉換工作排程偏差偏離監控，請將 `BatchTransformInput` 執行個體傳遞至 `ModelBiasModelMonitor` 執行個體的 `batch_transform_input` 引數，如下列程式碼範例所示：

```
from sagemaker.model_monitor import CronExpressionGenerator
                
model_bias_monitor = ModelBiasModelMonitor(
    role=sagemaker.get_execution_role(),
    ...
)

model_bias_analysis_config = None
if not model_bias_monitor.latest_baselining_job:
    model_bias_analysis_config = BiasAnalysisConfig(
        model_bias_config,
        headers=all_headers,
        label=label_header,
    )
    
schedule = model_bias_monitor.create_monitoring_schedule(
   monitor_schedule_name=schedule_name,
   post_analytics_processor_script=s3_code_postprocessor_uri,
   output_s3_uri=s3_report_path,
   statistics=model_bias_monitor.baseline_statistics(),
   constraints=model_bias_monitor.suggested_constraints(),
   schedule_cron_expression=CronExpressionGenerator.hourly(),
   enable_cloudwatch_metrics=True,
   analysis_config=model_bias_analysis_config,
   batch_transform_input=BatchTransformInput(
        destination="opt/ml/processing/input",
        data_captured_destination_s3_uri=s3_capture_path,
        start_time_offset="-PT1H",
        end_time_offset="-PT0H",
        probability_threshold_attribute=0.8
   ),
)
```

# 檢查報告中的資料偏差偏離
<a name="clarify-model-monitor-bias-drift-report"></a>

如果您無法在 SageMaker Studio 中所產生的報告中檢查監控結果，您可以將其列印出來，如下所示：

```
schedule_desc = model_bias_monitor.describe_schedule()
execution_summary = schedule_desc.get("LastMonitoringExecutionSummary")
if execution_summary and execution_summary["MonitoringExecutionStatus"] in ["Completed", "CompletedWithViolations"]:
    last_model_bias_monitor_execution = model_bias_monitor.list_executions()[-1]
    last_model_bias_monitor_execution_report_uri = last_model_bias_monitor_execution.output.destination
    print(f'Report URI: {last_model_bias_monitor_execution_report_uri}')
    last_model_bias_monitor_execution_report_files = sorted(S3Downloader.list(last_model_bias_monitor_execution_report_uri))
    print("Found Report Files:")
    print("\n ".join(last_model_bias_monitor_execution_report_files))
else:
    last_model_bias_monitor_execution = None
    print("====STOP==== \n No completed executions to inspect further. Please wait till an execution completes or investigate previously reported failures.")
```

 如果與基準相比存在違規，則會在此列出：

```
if last_model_bias_monitor_execution:
    model_bias_violations = last_model_bias_monitor_execution.constraint_violations()
    if model_bias_violations:
        print(model_bias_violations.body_dict)
```

如果您的模型部署到即時端點，您可以選擇**端點**索引標籤，然後按兩下端點，在 SageMaker AI Studio 中查看分析結果和 CloudWatch 指標的視覺效果。

# 偏差偏離分析的 CloudWatch 指標
<a name="clarify-model-monitor-bias-drift-cw"></a>

本指南顯示可在 SageMaker Clarify 中用於偏差偏離分析的 CloudWatch 指標及其屬性。偏差偏離監控工作會計算[訓練前偏差指標](https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-measure-data-bias.html)和[訓練後偏差指標](https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-measure-post-training-bias.html)，並將其發佈到下列 CloudWatch 命名空間：
+ 對於即時端點：`aws/sagemaker/Endpoints/bias-metrics`
+ 對於批次轉換工作：`aws/sagemaker/ModelMonitoring/bias-metrics`

CloudWatch 指標名稱會將指標的簡短名稱附加至 `bias_metric`。

例如，`bias_metric_CI` 是類別不平衡 (CI) 的偏差指標。

**注意**  
`+/- infinity` 發佈為浮點數 `+/- 2.348543e108`，而包括 null 值的錯誤不會發佈。

每個指標都具有下列屬性：
+ `Endpoint`：受監控端點的名稱(如果適用)。
+ `MonitoringSchedule`：監控工作排程的名稱。
+ `BiasStage`：偏差偏離監控工作的階段名稱。選擇 `Pre-training` 或 `Post-Training`。
+ `Label`：目標功能的名稱，由監控工作分析組態 `label` 提供。
+ `LabelValue`：目標功能的值，由監控工作分析組態 `label_values_or_threshold` 提供。
+ `Facet`：構面的名稱，由監控工作分析組態構面 `name_of_index` 提供。
+ `FacetValue`：構面的值，由監控工作分析組態構面 `nvalue_or_threshold` 提供。

若要停止發佈指標的監控工作，請在[模型偏差工作](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModelBiasJobDefinition.html)定義的 `Environment` 對應中將 `publish_cloudwatch_metrics` 設定為 `Disabled`。