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.2.tar.gz (158.7 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.2-py3-none-any.whl (205.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unbiased-0.0.2.tar.gz
  • Upload date:
  • Size: 158.7 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.2.tar.gz
Algorithm Hash digest
SHA256 e8e7be13d09fe8407f6d15d662a7c5789f65f6df6ddd0e24bb62e9070962e929
MD5 2fe60454bf03781ffdab3db65529ad13
BLAKE2b-256 ad703253fcbba095753e34f38e459b490322da715c4087a6549ad5710cbb24ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unbiased-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 205.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2bddff6d1e38dada29feb4813dc34d66d0b82b32f6a20825169bfdfca6cebea
MD5 888cee3eb8cd909962ca57443a47f335
BLAKE2b-256 4c1fdbf72aae685c78cdd3a855d4b379eeac3117458233681046b7093e95b0b5

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