限制條件的結構描述 (constraints.json 檔案) - Amazon SageMaker

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

限制條件的結構描述 (constraints.json 檔案)

constraints.json 檔案是用來表達資料集必須滿足的限制條件。Amazon SageMaker 模型監控器容器可以使用約束 .json 檔案來評估資料集。預先建置的容器能夠為基準資料集自動產生 constraints.json 檔案。如果您使用自有容器,則可以在容器中提供類似的功能,或者,您可以用其他方式建立 constraints.json 檔案。以下是預先建置的容器所使用的限制條件檔案的結構描述。使用自有容器可以採用相同的格式,或依需要來增強。

{ "version": 0, "features": [ { "name": "string", "inferred_type": "Integral" | "Fractional" | | "String" | "Unknown", "completeness": number, "num_constraints": { "is_non_negative": boolean }, "string_constraints": { "domains": [ "list of", "observed values", "for small cardinality" ] }, "monitoringConfigOverrides": {} } ], "monitoring_config": { "evaluate_constraints": "Enabled", "emit_metrics": "Enabled", "datatype_check_threshold": 0.1, "domain_content_threshold": 0.1, "distribution_constraints": { "perform_comparison": "Enabled", "comparison_threshold": 0.1, "comparison_method": "Simple"||"Robust", "categorical_comparison_threshold": 0.1, "categorical_drift_method": "LInfinity"||"ChiSquared" } } }

monitoring_config 物件包含用於監控功能工作的選項。下表描述各個選項。

監控限制條件
限制條件 描述
evaluate_constraints

Enabled 時,評估目前分析的資料集是否滿足 constraints.json 檔案 (作為基準) 中指定的限制條件。

有效值:EnabledDisabled

預設:Enabled

emit_metrics

何時Enabled,會針對檔案中包含的資料發出 CloudWatch 度量。

有效值:EnabledDisabled

預設:Enabled

datatype_check_threshold

如果臨界值高於 datatype_check_threshold 指定的值,這會導致失敗,而在違規報告中視為違規。如果目前執行與基準資料集的資料類型不相同,則會使用此臨界值來評估是否需要標記為違規。

在基準步驟期間,產生的限制條件會針對每個欄,建議推斷的資料類型。您可以調校 datatype_check_threshold 參數,以調整何時標記為違規的臨界值。

有效值:浮點數

預設:0.1

domain_content_threshold

如果目前資料集的某個字串欄位的未知值比基準資料集更多,則可以使用此臨界值來決定是否需要標記為違規。

有效值:浮點數

預設:0.1

distribution_constraints perform_comparison

Enabled 時,此旗標指示程式碼在基準分佈與目前資料集觀察到的分佈之間,執行分佈比較。

有效值:EnabledDisabled

預設:Enabled

comparison_threshold

如果臨界值高於 comparison_threshold 設定的值,這會導致失敗,而在違規報告中視為違規。在兩個分佈的累積分佈函式之間,取得最大絕對差量,即可算出距離。

有效值:浮點數

預設:0.1

comparison_method

是否計算 linf_simplelinf_robustlinf_simple 以兩個分佈的累積分佈函式之間的最大絕對差量為基礎。計算 linf_robust 是以 linf_simple 為基礎,但在沒有足夠的樣本時使用。linf_robust 公式以雙樣本 Kolmogorov–Smirnov 檢定為基礎。

有效值:linf_simplelinf_robust

categorical_comparison_threshold

選用。設定分類特徵的閾值。如果資料集中的值超過您設定的閾值,違規會記錄在違規報告中。

有效值:浮點數

預設值:指派給 comparison_threshold 參數的值

categorical_drift_method

選用。對於分類特徵,指定用於偵測分佈偏離的計算方法。如果您沒有設定此參數,系統會使用 K-S (Linfinity) 測試。

有效值:LInfinityChiSquared

預設:LInfinity