Skip to main content

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.

The R packages can be installed with the install_r_packages command from the BIAS toolbox.

Install the BIAS toolbox using pip:

pip install struct-bias

Then install the required R packages

from BIAS import install_r_packages

#run first time to install required R packages
install_r_packages()

This installs the following R packages:

  • PoweR
  • AutoSEARCH
  • nortest
  • data.table
  • goftest
  • ddst

Detailed setup using virtual env

  1. Download and install R from https://cran.r-project.org/
  2. Download this repository (clone or as zip)
  3. Create a python virtual env python -m venv env
  4. Activate the env (in powershell for example: env/Scripts/Activate.ps1 )
  5. Install dependencies pip install -r requirements.txt
  6. 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.

Citation

If you use the BIAS toolbox in a scientific publication, we would appreciate using the following citations:

@ARTICLE{9828803,
  author={Vermetten, Diederick and van Stein, Bas and Caraffini, Fabio and Minku, Leandro L. and Kononova, Anna V.},
  journal={IEEE Transactions on Evolutionary Computation}, 
  title={BIAS: A Toolbox for Benchmarking Structural Bias in the Continuous Domain}, 
  year={2022},
  volume={26},
  number={6},
  pages={1380-1393},
  doi={10.1109/TEVC.2022.3189848}
}

@software{niki_van_stein_2023_7803623,
  author       = {Niki van Stein and
                  Diederick Vermetten},
  title        = {Basvanstein/BIAS: v1.1 Deep-BIAS Toolbox},
  month        = apr,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {v1.1},
  doi          = {10.5281/zenodo.7803623},
  url          = {https://doi.org/10.5281/zenodo.7803623}
}

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

struct-bias-1.2.4.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

struct_bias-1.2.4-py3-none-any.whl (122.0 kB view details)

Uploaded Python 3

File details

Details for the file struct-bias-1.2.4.tar.gz.

File metadata

  • Download URL: struct-bias-1.2.4.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for struct-bias-1.2.4.tar.gz
Algorithm Hash digest
SHA256 f6b403497091e878bc6571a601ebcaaf04fa1fe75a516da7bf22b3c9ae41abf6
MD5 d231c85f8df3a7610cdd8fd9df82c36b
BLAKE2b-256 408747b6cebf0cd2e0bcfc9f2a953d088f57195731878e131bf3a3f2b890e862

See more details on using hashes here.

File details

Details for the file struct_bias-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: struct_bias-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 122.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for struct_bias-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8cdacb73755ac38a8088ab493167733d8e1e7fa5454fc79dbea8bf1a2019d3ba
MD5 5221e4dec9414120ef7b604f8ce317c8
BLAKE2b-256 5958b629e40fa21a913d9b00628bd1dda804992cb1b7ce4482bc195839d27c32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page