BIAS toolbox: Structural bias detection for continuous optimization algorithms
Project description
Deep-BIAS: Bias In Algorithms, Structural
A toolbox for detecting structural bias in continuous optimization heuristics.
With a deep-learning extension to better evaluate the type of bias and gain insights using explainable AI
Setup
This package requires an R-installation to be present, with the following packages installed:
- PoweR
- AutoSEARCH
- nortest
- data.table
- goftest
- ddst
Then install via pip:
pip install struct-bias
Detailed setup using virtual env
- Download and install R from https://cran.r-project.org/
- Download this repository (clone or as zip)
- Create a python virtual env
python -m venv env
- Activate the env (in powershell for example:
env/Scripts/Activate.ps1
) - Install dependencies
pip install -r requirements.txt
- Checkout the
example.py
to start using the BIAS toolbox.
Example
#example of using the BIAS toolbox to test a DE algorithm
from scipy.optimize import differential_evolution
import numpy as np
from BIAS import BIAS, f0, install_r_packages
#run first time to install required R packages
install_r_packages()
bounds = [(0,1), (0, 1), (0, 1), (0, 1), (0, 1)]
#do 30 independent runs (5 dimensions)
samples = []
print("Performing optimization method 30 times of f0.")
for i in np.arange(30):
result = differential_evolution(f0, bounds, maxiter=100)
samples.append(result.x)
samples = np.array(samples)
test = BIAS()
print(test.predict(samples, show_figure=True))
y, preds = test.predict_deep(samples)
test.explain(samples, preds, filename="explanation.png")
Additional files
Note: The code for generating the RF used to predict the type of bias is included, but the full RF is not. These can be found on zenodo: https://doi.org/10.6084/m9.figshare.16546041. The RF models will be downloaded automatically the first time the predict function requires them.
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
struct-bias-1.2.3.tar.gz
(15.5 kB
view details)
Built Distribution
File details
Details for the file struct-bias-1.2.3.tar.gz
.
File metadata
- Download URL: struct-bias-1.2.3.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 610609de28b86e35ac6014de11fdb3b1f488f7ecd633739364b13602d74496ed |
|
MD5 | 09b5bde3c05fc384bd3f09a111dab1cc |
|
BLAKE2b-256 | 998952154581906f1cc718f56f980c62a7ab74c8f228905911a5c1fecfbc306c |
File details
Details for the file struct_bias-1.2.3-py3-none-any.whl
.
File metadata
- Download URL: struct_bias-1.2.3-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d7452c33f14625003ac09072ef1862e21dbe029a7636c277fdef4eaec9f241c |
|
MD5 | 99d77b06b1342d1c4fc7b076fb3edfbf |
|
BLAKE2b-256 | 2dc9791e7e37462443788cf248df5392a8aa5fd82e2e160b3f257691df51e7ec |