Skip to main content

Comprehensive bias detection and mitigation for datasets, models, and LLM agents

Project description

Unbiased

Comprehensive bias detection and mitigation for datasets, models, and LLM agents

Unbiased is a Python library that provides end-to-end fairness auditing across the entire ML pipeline - from raw data to deployed AI agents.

Features

🗂️ Dataset Audit

Detect statistical biases in tabular datasets before model training:

  • Representation analysis (demographic imbalances)
  • Label bias detection (outcome disparities)
  • Proxy feature detection (hidden correlations)
  • Missing data patterns
  • Intersectional disparities
  • KL divergence analysis

🤖 Model Audit

Audit trained ML models for fairness violations:

  • Counterfactual flip testing
  • 5 group fairness metrics (Demographic Parity, Disparate Impact, Equalized Odds, etc.)
  • Intersectional bias analysis
  • Automatic severity classification
  • Mitigation recommendations

🧠 Agent Audit

Black-box bias auditing for LLM agents:

  • System prompt auditing
  • API endpoint testing
  • Log replay analysis
  • Persona-based counterfactual testing
  • Statistical bias detection (CFR, MASD)
  • Prompt surgery recommendations

Installation

# Basic installation (dataset and model audit)
pip install unbiased

# With LLM agent audit support
pip install unbiased[agent]

# With report generation (PDF, visualizations)
pip install unbiased[reports]

# Full installation with all features
pip install unbiased[all]

Quick Start

Dataset Audit

from unbiased import audit_dataset

report = audit_dataset(
    data='hiring_data.csv',
    protected_attributes=['gender', 'race'],
    target_column='hired',
    positive_value=1
)

print(f"Severity: {report.overall_severity}")
print(f"Findings: {len(report.findings)}")
report.export('dataset_audit.json')

Model Audit

from unbiased.model_audit import audit_model

report = audit_model(
    model='trained_model.pkl',
    test_data='test.csv',
    protected_attributes=['gender', 'race'],
    target_column='hired',
    positive_value=1
)

print(f"Severity: {report.overall_severity}")
for finding in report.findings:
    print(f"- {finding.title}: {finding.severity}")

Agent Audit

from unbiased.agent_audit import audit_agent

report = await audit_agent(
    system_prompt="You are a hiring assistant...",
    seed_case="Evaluate candidate: Name: Alex...",
    api_key="your-api-key"
)

print(f"Bias detected: {report.has_bias}")
print(f"CFR: {report.cfr:.3f}")

Documentation

Requirements

  • Python 3.8+
  • pandas >= 2.0.0
  • numpy >= 1.24.0
  • scipy >= 1.10.0
  • scikit-learn >= 1.3.0

Optional Dependencies

  • Agent audit: groq, openai, anthropic, aiohttp
  • Reports: reportlab, matplotlib
  • Embeddings: sentence-transformers
  • LangGraph: langgraph, langchain

Research Foundation

Unbiased implements methods from cutting-edge fairness research:

  • CAFFE (Parziale et al. 2025) - Counterfactual fairness evaluation
  • CFR/MASD (Mayilvaghanan et al. 2025) - Statistical bias metrics
  • Hardt et al. (2016) - Equality of opportunity
  • Chouldechova (2017) - Fair prediction with disparate impact
  • EEOC Guidelines - 80% rule for disparate impact

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Citation

If you use Unbiased in your research, please cite:

@software{unbiased2025,
  title={Unbiased: Comprehensive Bias Detection and Mitigation Library},
  author={NoBias Team},
  year={2025},
  url={https://github.com/nobias/unbiased}
}

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unbiased-0.0.0.tar.gz (134.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unbiased-0.0.0-py3-none-any.whl (177.5 kB view details)

Uploaded Python 3

File details

Details for the file unbiased-0.0.0.tar.gz.

File metadata

  • Download URL: unbiased-0.0.0.tar.gz
  • Upload date:
  • Size: 134.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for unbiased-0.0.0.tar.gz
Algorithm Hash digest
SHA256 0686ba5a74e23621669b3cc508308c0d5696de58be44f9499df546f51af96701
MD5 688bbefb9d5679c12b33830abaaa667f
BLAKE2b-256 a8d62b242fba3f3a0150e380f8d0f42217860d98a81b2f3010fd07a6dfb9230b

See more details on using hashes here.

File details

Details for the file unbiased-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: unbiased-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 177.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for unbiased-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f703200824e1624d31e0ccb5199e73560c37066de25243a42a292dd9f000a80
MD5 7164c99fc4d6c402118336cf33b44ceb
BLAKE2b-256 fec5c8494b579e350d422d4ad432b12b1abef906e6dc0ac377944137c5427d78

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page