SageMaker Clarify for Bias Detection: A Compliance Guide
Bias in machine learning models is no longer just an ethical concern -- it is a compliance obligation. The EU AI Act mandates bias testing for high-risk AI systems. NIST AI RMF requires documented fairness evaluation. SOC 2 auditors are increasingly asking for evidence that your models treat demographic groups equitably. If you cannot demonstrate that you have tested for bias and acted on the results, you have a gap in your compliance program.
Amazon SageMaker Clarify is AWS's native service for detecting bias in training data and deployed models. It computes industry-standard fairness metrics, generates explainability reports, and integrates with SageMaker Pipelines for automated testing. This guide walks through what Clarify does, how to interpret its metrics, how to operationalize bias detection for compliance, and how each capability maps to the frameworks your auditors care about.
What SageMaker Clarify Does
Clarify provides three categories of analysis that together cover the full lifecycle of ML fairness:
Pre-training bias detection examines your training dataset before a model is built. It identifies imbalances in label distribution across demographic groups. If your training data systematically underrepresents a protected class or assigns unfavorable labels disproportionately, Clarify quantifies the disparity. This matters because biased training data produces biased models -- catching the problem at the data stage is cheaper and more effective than catching it after deployment.
Post-training bias detection evaluates a trained model's predictions against a validation dataset. Even when training data appears balanced, models can learn discriminatory patterns through feature correlations. Post-training metrics compare outcomes across groups defined by sensitive attributes like gender, race, age bracket, or geographic region.
Explainability analysis uses SHAP (SHapley Additive exPlanations) values to attribute each prediction to individual input features. Explainability is not strictly bias detection, but it is essential for compliance. When an auditor asks why your model denied a loan application or flagged a transaction, you need feature-level attribution -- not just a probability score.
For a broader view of how Clarify fits into the AWS AI governance landscape, see the Complete Guide to AWS AI/ML Governance.
Key Bias Metrics Explained
Clarify computes over 20 bias metrics. For compliance purposes, three are essential: Difference in Positive Proportions in Labels (DPPL), Disparate Impact (DI), and Difference in Conditional Rejection (DCR). Understanding what each metric measures -- and what thresholds to set -- is critical for producing audit-ready evidence.
Difference in Positive Proportions in Labels (DPPL)
DPPL is a pre-training metric. It measures the difference in the proportion of positive labels between a favored group and a disfavored group. The formula is: DPPL = (positive_labels_favored / total_favored) - (positive_labels_disfavored / total_disfavored).
A DPPL of 0 means perfect parity. Positive values indicate bias toward the favored group; negative values indicate bias toward the disfavored group. In practice, a DPPL within the range of -0.1 to +0.1 is generally considered acceptable, but your compliance program should define explicit thresholds based on your risk tolerance and regulatory context.
Compliance relevance: DPPL maps directly to EU AI Act Article 10, which requires providers of high-risk AI systems to examine training data for possible biases. If DPPL exceeds your threshold, you have documented evidence of data-level bias that must be addressed before model training.
Disparate Impact (DI)
DI is a post-training metric derived from employment discrimination law (the "four-fifths rule"). It measures the ratio of positive outcomes between the disfavored and favored groups: DI = (positive_outcomes_disfavored / total_disfavored) / (positive_outcomes_favored / total_favored).
A DI of 1.0 means perfect parity. Values below 0.8 are generally considered evidence of adverse impact under US employment law. The EU AI Act does not prescribe specific thresholds, but the 0.8 rule is widely adopted as a defensible baseline.
Compliance relevance: DI is the most recognized fairness metric in regulatory contexts. For ISO 42001 clause 8.5 (bias management), documenting your DI values per demographic group -- along with any remediation actions taken when DI drops below threshold -- constitutes strong compliance evidence.
Difference in Conditional Rejection (DCR)
DCR measures whether the model rejects (assigns negative outcomes to) members of the disfavored group at a higher rate than the favored group, conditional on the actual labels. It captures scenarios where a model disproportionately rejects qualified members of a disfavored group. The formula is: DCR = (rejected_with_positive_label_disfavored / total_positive_label_disfavored) - (rejected_with_positive_label_favored / total_positive_label_favored).
DCR complements DI by focusing specifically on false negatives. A model can have acceptable DI but problematic DCR if it systematically denies qualified applicants from a specific group.
Compliance relevance: NIST AI RMF subcategory MG.3.2 requires organizations to manage identified risks, including bias. DCR provides granular evidence that your model does not systematically reject qualified members of protected groups, which is precisely the kind of harm MG.3.2 is designed to prevent.
Running a Pre-Training Bias Detection Job
Before training a model, run Clarify against your dataset to identify data-level bias. The following example analyzes a loan application dataset for bias across the gender attribute.
import boto3
from sagemaker.clarify import (
SageMakerClarifyProcessor,
DataConfig,
BiasConfig,
)
clarify_processor = SageMakerClarifyProcessor(
role="arn:aws:iam::123456789:role/SageMakerClarifyRole",
instance_count=1,
instance_type="ml.m5.xlarge",
sagemaker_session=sagemaker.Session(),
)
data_config = DataConfig(
s3_data_input_path="s3://ml-data/loans/training/applicants.csv",
s3_output_path="s3://ml-governance/clarify/loans-v2/pre-training",
label="approved",
headers=[
"applicant_id", "age", "gender", "income",
"credit_score", "debt_ratio", "region", "approved",
],
dataset_type="text/csv",
)
bias_config = BiasConfig(
label_values_or_threshold=[1],
facet_name="gender",
facet_values_or_threshold=["Female"],
group_name="region",
)
clarify_processor.run_pre_training_bias(
data_config=data_config,
bias_config=bias_config,
methods="all",
job_name="loans-v2-pre-training-bias-2026-04",
)
The methods="all" parameter tells Clarify to compute every available pre-training metric, including DPPL, Class Imbalance (CI), Kullback-Leibler divergence (KL), and Jensen-Shannon divergence (JS). The output is written to S3 as a JSON report and a human-readable PDF. Both are audit artifacts.
Compliance Tip: Always use a dated
job_nameso that your S3 output path creates a time-ordered audit trail. When an auditor asks for bias testing evidence from Q1, you can point to the specific job execution and its results.
Running a Post-Training Bias Detection Job
Post-training bias detection requires a trained model. Clarify sends your validation data through the model, collects predictions, and computes outcome-based bias metrics including DI, DCR, and Treatment Equality (TE).
from sagemaker.clarify import ModelConfig, ModelPredictedLabelConfig
model_config = ModelConfig(
model_name="loan-approval-v2",
instance_count=1,
instance_type="ml.m5.xlarge",
content_type="text/csv",
accept_type="application/json",
)
predicted_label_config = ModelPredictedLabelConfig(
probability_threshold=0.5,
)
data_config = DataConfig(
s3_data_input_path="s3://ml-data/loans/validation/applicants.csv",
s3_output_path="s3://ml-governance/clarify/loans-v2/post-training",
label="approved",
headers=[
"applicant_id", "age", "gender", "income",
"credit_score", "debt_ratio", "region", "approved",
],
dataset_type="text/csv",
)
bias_config = BiasConfig(
label_values_or_threshold=[1],
facet_name="gender",
facet_values_or_threshold=["Female"],
)
clarify_processor.run_post_training_bias(
data_config=data_config,
bias_config=bias_config,
model_config=model_config,
model_predicted_label_config=predicted_label_config,
methods="all",
job_name="loans-v2-post-training-bias-2026-04",
)
Post-training metrics are the most important evidence for compliance. Pre-training metrics tell you about your data; post-training metrics tell you about the decisions your model actually makes.
Interpreting Results for Compliance
Clarify outputs are JSON files in S3. Here is how to extract and interpret the key metrics programmatically for compliance reporting.
import boto3
import json
s3 = boto3.client("s3")
response = s3.get_object(
Bucket="ml-governance",
Key="clarify/loans-v2/post-training/analysis.json",
)
report = json.loads(response["Body"].read().decode("utf-8"))
# Extract post-training metrics for the "gender" facet
facet_results = report["post_training_bias_metrics"]["facets"]["gender"][0]
metrics = facet_results["metrics"]
compliance_summary = {
"model": "loan-approval-v2",
"analysis_date": "2026-04-21",
"facet": "gender",
"facet_value": "Female",
"disparate_impact": metrics["DI"]["value"],
"di_passes_threshold": metrics["DI"]["value"] >= 0.8,
"dppl": metrics["DPPL"]["value"],
"dppl_passes_threshold": abs(metrics["DPPL"]["value"]) <= 0.1,
"dcr": metrics["DCR"]["value"],
"dcr_passes_threshold": abs(metrics["DCR"]["value"]) <= 0.1,
}
print(json.dumps(compliance_summary, indent=2))
# Flag failures for remediation
failures = [
metric for metric, passes in compliance_summary.items()
if metric.endswith("_passes_threshold") and not passes
]
if failures:
print(f"\nCOMPLIANCE ALERT: {len(failures)} metric(s) exceeded threshold")
print("Remediation required before production deployment")
The key compliance interpretation rules are:
- DI below 0.8: Adverse impact detected. Document the finding, investigate root causes (feature correlations, training data imbalance), and retrain or apply mitigation techniques before deployment.
- DPPL outside +/- 0.1: Data-level bias detected. Investigate training data collection methodology. Consider resampling, reweighting, or augmenting the training set.
- DCR outside +/- 0.1: The model disproportionately rejects qualified members of the disfavored group. Review the decision threshold and evaluate whether a group-specific threshold is appropriate.
Every Clarify report should be stored in a compliance-designated S3 bucket with versioning enabled and lifecycle policies that match your retention requirements. For most frameworks, three years is the minimum.
Scheduling Automated Bias Checks
Running bias detection manually is error-prone and does not satisfy continuous compliance requirements. Use SageMaker Pipelines to schedule automated Clarify jobs that run on a defined cadence.
from sagemaker.workflow.pipeline import Pipeline
from sagemaker.workflow.steps import ClarifyCheckStep
from sagemaker.workflow.check_job_config import CheckJobConfig
from sagemaker.workflow.clarify_check_step import (
DataBiasCheckConfig,
ModelBiasCheckConfig,
)
check_job_config = CheckJobConfig(
role="arn:aws:iam::123456789:role/SageMakerClarifyRole",
instance_count=1,
instance_type="ml.m5.xlarge",
volume_size_in_gb=30,
max_runtime_in_seconds=3600,
)
data_bias_check_config = DataBiasCheckConfig(
data_config=data_config,
data_bias_config=bias_config,
methods="all",
)
model_bias_check_config = ModelBiasCheckConfig(
data_config=data_config,
data_bias_config=bias_config,
model_config=model_config,
model_predicted_label_config=predicted_label_config,
methods="all",
)
data_bias_step = ClarifyCheckStep(
name="WeeklyDataBiasCheck",
clarify_check_config=data_bias_check_config,
check_job_config=check_job_config,
skip_check=False,
register_new_baseline=False,
supplied_baseline_constraints="s3://ml-governance/clarify/baselines/data-bias-constraints.json",
)
model_bias_step = ClarifyCheckStep(
name="WeeklyModelBiasCheck",
clarify_check_config=model_bias_check_config,
check_job_config=check_job_config,
skip_check=False,
register_new_baseline=False,
supplied_baseline_constraints="s3://ml-governance/clarify/baselines/model-bias-constraints.json",
)
pipeline = Pipeline(
name="loan-approval-bias-monitoring",
steps=[data_bias_step, model_bias_step],
)
pipeline.upsert(role_arn="arn:aws:iam::123456789:role/SageMakerPipelineRole")
Schedule this pipeline to run weekly using Amazon EventBridge:
aws events put-rule \
--name "weekly-bias-check-loans-v2" \
--schedule-expression "cron(0 6 ? * MON *)" \
--state ENABLED \
--description "Weekly Clarify bias check for loan-approval-v2"
aws events put-targets \
--rule "weekly-bias-check-loans-v2" \
--targets '[{
"Id": "SageMakerPipelineTarget",
"Arn": "arn:aws:sagemaker:us-east-1:123456789:pipeline/loan-approval-bias-monitoring",
"RoleArn": "arn:aws:iam::123456789:role/EventBridgeSageMakerRole",
"SageMakerPipelineParameters": {
"PipelineParameterList": [
{"Name": "RunDate", "Value": "<aws.scheduler.execution-id>"}
]
}
}]'
Weekly automated bias checks satisfy the "continuous" aspect of compliance monitoring. When an auditor asks how frequently you test for bias, you can point to the EventBridge rule, the pipeline execution history, and the S3 bucket full of dated Clarify reports.
Compliance Mapping Table
The following table maps SageMaker Clarify capabilities to specific compliance framework requirements. Use this to build your controls matrix and trace each Clarify feature to the regulatory clause it satisfies.
| Clarify Capability | ISO 42001 | NIST AI RMF | EU AI Act | SOC 2 | Evidence Artifact |
|---|---|---|---|---|---|
| Pre-training bias metrics (DPPL, CI, KL) | 8.5 (bias management) | MG.3.2 (risk management) | Article 10(2)(f) -- bias examination | CC4.1 (monitoring activities) | Pre-training bias report (JSON/PDF) |
| Post-training bias metrics (DI, DCR, TE) | 8.5 (bias management) | MG.3.2 (risk management) | Article 10(2)(f) -- bias examination | CC4.1 (monitoring activities) | Post-training bias report (JSON/PDF) |
| SHAP explainability reports | 8.4 (AI system documentation) | MP.5.2 (interpretability) | Article 13 (transparency) | CC4.1 (monitoring activities) | Feature attribution report |
| Baseline constraints | 9.1 (performance evaluation) | MS.2.3 (monitoring metrics) | Article 9(2) -- risk management | CC7.1 (system monitoring) | Baseline constraints JSON |
| Automated pipeline integration | 9.1 (performance evaluation) | MG.3.2 (risk management) | Article 9(2) -- risk management | CC7.1 (system monitoring) | Pipeline execution history |
| Scheduled bias monitoring | 9.1 (performance evaluation) | MS.2.3 (monitoring metrics) | Article 9(9) -- post-market monitoring | CC7.1 (system monitoring) | EventBridge rule + execution logs |
Key Takeaway: Clarify alone does not make you compliant. It provides the data. Compliance requires that you define thresholds, act on violations, document remediation, and maintain an audit trail of every analysis. The metrics are the evidence; your process around them is the control.
How Claw GRC Automates Clarify Evidence Collection
Running Clarify jobs and storing reports in S3 is the first step. The second step -- the one most teams skip -- is connecting those reports to your compliance program so that auditors can trace a direct line from a regulatory requirement to a specific bias analysis result.
Claw GRC automates this connection:
Automated report ingestion. Claw GRC monitors your Clarify output S3 buckets and automatically ingests new bias analysis reports. Each report is parsed, indexed, and linked to the relevant model in your model inventory.
Threshold-based compliance findings. When a Clarify metric exceeds your configured threshold (for example, DI drops below 0.8), Claw GRC generates a compliance finding linked to the applicable framework controls -- ISO 42001 8.5, NIST AI RMF MG.3.2, and EU AI Act Article 10. The finding includes the metric value, the threshold, and recommended remediation steps.
Evidence mapping. Each Clarify report is automatically mapped to the compliance framework controls it satisfies. When an auditor requests evidence for ISO 42001 clause 8.5, Claw GRC produces every Clarify report associated with that control, filtered by date range and model.
Trend tracking. Claw GRC tracks bias metrics over time, surfacing trends that individual reports cannot reveal. If your DI for a specific demographic group has been declining over three consecutive months, Claw GRC flags the trend before it crosses the compliance threshold. This is proactive governance, not reactive remediation.
Integration with Model Cards. Clarify results flow directly into your SageMaker Model Cards, ensuring that model documentation always reflects the latest bias analysis. Combined with ML Lineage Tracking, you get full traceability from training data through bias analysis to deployed model.
Next Steps
Bias detection is one pillar of a comprehensive AI governance program. To build out the full picture:
- Complete Guide to AWS AI/ML Governance -- the hub article covering all 10 governance pillars
- SageMaker Model Cards for Compliance -- documenting your models with bias analysis results
- SageMaker ML Lineage Tracking -- tracing data provenance from training set to production model
Each guide includes hands-on code examples, compliance mapping tables, and evidence collection strategies you can implement today.