A toolkit for detecting and explaining gender bias in face classification models
Project description
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: biasx-framework.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}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file biasx-0.1.2.tar.gz.
File metadata
- Download URL: biasx-0.1.2.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abeda9ba5f3c6777cce11522f5ad7ffc06e56afa92fe3059640666fb9d129487
|
|
| MD5 |
fb8e5425dad8b7c428b647792f672908
|
|
| BLAKE2b-256 |
0fe050791d1e4055487a1d3384e8c6cfb13171b6fc63e559a8a4f911bda9b2cc
|
File details
Details for the file biasx-0.1.2-py3-none-any.whl.
File metadata
- Download URL: biasx-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f060f81cf87f17d3baaa8252bd45d596277e8fad294f883e7316a7f28efe814f
|
|
| MD5 |
8d4115b575cc0fb2ed32e0b4b60def71
|
|
| BLAKE2b-256 |
d7b4f257879728b07c6df2c60a2bc3f1f7fcdfa10b439cfa3288144e7adeec62
|