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.1.tar.gz (152.6 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.1-py3-none-any.whl (199.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unbiased-0.0.1.tar.gz
Algorithm Hash digest
SHA256 402e76320537f8dd1f05a13021b058509247b4561e1e08012640d955c90a109f
MD5 3d819ea563d7103a50d0d94900a97702
BLAKE2b-256 9e3513be9a69f45094e48fb642c51a119cfaf98187f5450f5960535ab556206b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for unbiased-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 035f76078caf5bde1f7115a69e0177ed901377dd1b5cb932c13403e92cc855b8
MD5 aa0a507fa10b3df98a2f2f564c444175
BLAKE2b-256 a8d793dfd9d8312a4234a592c2360cbb58a22b2023beec771b52adeae8678c86

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