Skip to main content

BiasX

BiasX is a comprehensive framework for quantifying and explaining gender bias in face classification models using a feature-based approach. Rather than just measuring bias with traditional metrics, BiasX reveals which facial features contribute to gender-specific misclassifications, providing explainable and actionable insights.

Features

Feature Description
Feature-Level Bias Analysis Identifies bias contributions from specific facial features (eyes, nose, lips, etc.)
Visual Explanation Generation Creates activation maps to visualize model decision regions
Comprehensive Metrics Calculates both traditional (equalized odds) and feature-based bias scores
Dataset Management Handles facial image datasets with demographic attributes
Experiment Framework Supports controlled experiments with manipulated gender distributions and masked facial features
Interactive Visualization Includes a web application for exploring bias analysis results

Installation

From PyPI (Recommended)

BiasX is available on PyPI: https://pypi.org/project/biasx/

# Install directly from PyPI
pip install biasx

From Source (For Development)

# Clone the repository
git clone https://github.com/rixmape/biasx.git
cd biasx

# Install dependencies
pip install -r requirements.txt

# Install the package in development mode
pip install -e .

Quick Start

from biasx import BiasAnalyzer

# Configure the analyzer
config = {
    "model": {
        "path": "path/to/gender/classifier.keras",
    },
    "explainer": {
        "landmarker_source": "mediapipe",
        "cam_method": "gradcam++",
        "cutoff_percentile": 90,
        "threshold_method": "otsu",
        "overlap_threshold": 0.2,
        "distance_metric": "euclidean",
    },
    "dataset": {
        "source": "utkface",
        "image_width": 224,
        "image_height": 224,
        "color_mode": "L",
        "single_channel": False,
        "max_samples": 100,
        "shuffle": True,
        "seed": 69,
    },
}

# Run analysis
analyzer = BiasAnalyzer(config)
results = analyzer.analyze()

# Access results
print(f"Overall BiasX Score: {results.disparity_scores.biasx}")
print(f"Equalized Odds Score: {results.disparity_scores.equalized_odds}")

# View feature-specific bias
for feature, analysis in results.feature_analyses.items():
    print(f"{feature.value}: Bias Score = {analysis.bias_score}")

Web Application

The BiasX framework includes an interactive web application for visualizing and exploring bias analysis results.

Local Deployment

# Run locally
streamlit run app/app.py

# Or use the make command
make deploy

Public Deployment

The application is publicly available at: biasxframework.streamlit.app

Development

Run tests with coverage reporting:

pytest --cov=biasx --cov-report=term --cov-report=html

# Or use the make command
make test

License

This project is licensed under the MIT License. See the LICENSE file for details.

Citation

If you use BiasX in your research, please cite our work:

@article{biasx2023,
  title={BiasX: A Feature-Based Framework for Explaining and Quantifying Gender Bias in Face Classification},
  author={Lucero, J. G. and Mape, R. N. and Sy, J. W.},
  year={2025}
}

Metadata

Release files for biasx 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for biasx 0.1.3
File Size Uploaded
biasx-0.1.3.tar.gz 29.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for biasx 0.1.3
File Interpreter ABI Platform
biasx-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 61.6 kB

Release files / biasx-0.1.3.tar.gz

Download URL biasx-0.1.3.tar.gz
Size 29.2 kB
Tags Source
SHA-256 checksum
How to use checksums
586c4192fd5eaf0d2eac0eb1757a384bfebd7b9d7111fc1b2316808b4ffb2a84
BLAKE2b-256 checksum
How to use checksums
634576dd37de184c8dd7c63709c49733388963a1c7d5e1a441de71c98bfb6b5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / biasx-0.1.3-py3-none-any.whl

Download URL biasx-0.1.3-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1f41ceab0b9b610fedcb5c9f741cafe2f8e1355b8f30624ea13498e264283fe
BLAKE2b-256 checksum
How to use checksums
f1b602d21f14c09ff2c377e44b91f55decc14e70a67645d06f9e90789a3cf5d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page