

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

# 模型功能屬性偏離違規
<a name="clarify-model-monitor-model-attribution-drift-violations"></a>

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

以下是功能屬性偏離違規檔案的結構描述。
+ `label` – 標籤名稱、工作分析組態 `label_headers` 或預留位置，例如 `"label0"`。
+ `metric_name` – 可解釋性分析方法的名稱。目前僅支援 `shap`。
+ `constraint_check_type` – 監控的違規類型。目前僅支援 `feature_attribution_drift_check`。
+ `description` – 說明違規的描述訊息。

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

對於 `explanations` 區段中的每個標籤，監控工作會計算其在基準限制檔案和工作分析結果檔案 (*analysis.json*) 中的全域 SHAP 值的 [nDCG 分數](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.ndcg_score.html)。如果分數小於 0.9，會記錄違規。會評估合併的全域 SHAP 值，因此違規項目中沒有 `“feature”` 欄位。下列輸出提供幾個記錄違規的範例。

```
{
    "version": "1.0",
    "violations": [{
        "label": "label0",
        "metric_name": "shap",
        "constraint_check_type": "feature_attribution_drift_check",
        "description": "Feature attribution drift 0.7639720923277322 exceeds threshold 0.9"
    }, {
        "label": "label1",
        "metric_name": "shap",
        "constraint_check_type": "feature_attribution_drift_check",
        "description": "Feature attribution drift 0.7323763972092327 exceeds threshold 0.9"
    }]
}
```