All Projects → adebayoj → Fairml

adebayoj / Fairml

Licence: other

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Fairml

Q-server
Q server
Stars: ✭ 37 (-87.58%)
Mutual labels:  toolbox
dockerfiles
Dockerfiles everywhere 🐳
Stars: ✭ 17 (-94.3%)
Mutual labels:  toolbox
Neurokit
NeuroKit2: The Python Toolbox for Neurophysiological Signal Processing
Stars: ✭ 264 (-11.41%)
Mutual labels:  toolbox
MGT-python
Musical Gestures Toolbox for Python
Stars: ✭ 25 (-91.61%)
Mutual labels:  toolbox
shell-toolbox
Useful shell scripts for /bin/sh
Stars: ✭ 40 (-86.58%)
Mutual labels:  toolbox
MisakaLinuxToolbox
御坂妹妹们的Linux VPS工具箱
Stars: ✭ 237 (-20.47%)
Mutual labels:  toolbox
signalo
A DSP toolbox with focus on embedded environments written in Rust.
Stars: ✭ 71 (-76.17%)
Mutual labels:  toolbox
Vedadet
A single stage object detection toolbox based on PyTorch
Stars: ✭ 271 (-9.06%)
Mutual labels:  toolbox
SSPIM
SSPIM is a pattern producer for gray and binary spatial light modulators.
Stars: ✭ 21 (-92.95%)
Mutual labels:  toolbox
plenopticam
Light-field imaging application for plenoptic cameras
Stars: ✭ 111 (-62.75%)
Mutual labels:  toolbox
wsa-toolbox
A Windows 11 application to easily install and use the Windows Subsystem For Android™ package on your computer.
Stars: ✭ 438 (+46.98%)
Mutual labels:  toolbox
nltools
Python toolbox for analyzing imaging data
Stars: ✭ 94 (-68.46%)
Mutual labels:  toolbox
spire
🗼Extensible JavaScript toolbox management
Stars: ✭ 21 (-92.95%)
Mutual labels:  toolbox
template
A Vapor template for convenient and fast scaffolding 🏎
Stars: ✭ 33 (-88.93%)
Mutual labels:  toolbox
Visualplus
🎨 The VisualPlus Framework (VPF) for WinForms allows you to rapidly deploy professional .NET applications with customizable components and controls.
Stars: ✭ 268 (-10.07%)
Mutual labels:  toolbox
GA-Toolbox
Genetic Algorithms Toolbox
Stars: ✭ 41 (-86.24%)
Mutual labels:  toolbox
cookie-factory
Processing-style Scripting Add-on for Blender
Stars: ✭ 21 (-92.95%)
Mutual labels:  toolbox
Torch Toolbox
[Active development]ToolBox to make using Pytorch much easier.Give it a star if you feel helpful.
Stars: ✭ 268 (-10.07%)
Mutual labels:  toolbox
Arknights Toolbox
🔨 Arknights Toolbox, all servers are supported. 明日方舟工具箱,支持中台美日韩服
Stars: ✭ 271 (-9.06%)
Mutual labels:  toolbox
go-tools
A utility tool library of Golang.
Stars: ✭ 44 (-85.23%)
Mutual labels:  toolbox

========

Build Status Coverage Status GitHub license GitHub issues

FairML: Auditing Black-Box Predictive Models

FairML is a python toolbox auditing the machine learning models for bias.

Description

Predictive models are increasingly been deployed for the purpose of determining access to services such as credit, insurance, and employment. Despite societal gains in efficiency and productivity through deployment of these models, potential systemic flaws have not been fully addressed, particularly the potential for unintentional discrimination. This discrimination could be on the basis of race, gender, religion, sexual orientation, or other characteristics. This project addresses the question: how can an analyst determine the relative significance of the inputs to a black-box predictive model in order to assess the model’s fairness (or discriminatory extent)?

We present FairML, an end-to-end toolbox for auditing predictive models by quantifying the relative significance of the model’s inputs. FairML leverages model compression and four input ranking algorithms to quantify a model’s relative predictive dependence on its inputs. The relative significance of the inputs to a predictive model can then be used to assess the fairness (or discriminatory extent) of such a model. With FairML, analysts can more easily audit cumbersome predictive models that are difficult to interpret.s of black-box algorithms and corresponding input data.

Installation

You can pip install this package, via github - i.e. this repo - using the following commands:

pip install https://github.com/adebayoj/fairml/archive/master.zip

or you can clone the repository doing:

git clone https://github.com/adebayoj/fairml.git

sudo python setup.py install

Methodology

Code Demo

Now we show how to use the fairml python package to audit a black-box model.

"""
First we import modules for model building and data
processing.
"""
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression

"""
Now, we import the two key methods from fairml.
audit_model takes:

- (required) black-box function, which is the model to be audited
- (required) sample_data to be perturbed for querying the function. This has to be a pandas dataframe with no missing data.

- other optional parameters that control the mechanics of the auditing process, for example:
  - number_of_runs : number of iterations to perform
  - interactions : flag to enable checking model dependence on interactions.

audit_model returns an overloaded dictionary where keys are the column names of input pandas dataframe and values are lists containing model  dependence on that particular feature. These lists of size number_of_runs.

"""
from fairml import audit_model
from fairml import plot_generic_dependence_dictionary

Above, we provide a quick explanation of the key fairml functionality. Now we move into building an example model that we'd like to audit.

# read in the propublica data to be used for our analysis.
propublica_data = pd.read_csv(
    filepath_or_buffer="./doc/example_notebooks/"
    "propublica_data_for_fairml.csv")

# create feature and design matrix for model building.
compas_rating = propublica_data.score_factor.values
propublica_data = propublica_data.drop("score_factor", 1)


# this is just for demonstration, any classifier or regressor
# can be used here. fairml only requires a predict function
# to diagnose a black-box model.

# we fit a quick and dirty logistic regression sklearn
# model here.
clf = LogisticRegression(penalty='l2', C=0.01)
clf.fit(propublica_data.values, compas_rating)

Now let's audit the model built with FairML.

#  call audit model with model
total, _ = audit_model(clf.predict, propublica_data)

# print feature importance
print(total)

# generate feature dependence plot
fig = plot_dependencies(
    total.get_compress_dictionary_into_key_median(),
    reverse_values=False,
    title="FairML feature dependence"
)
plt.savefig("fairml_ldp.eps", transparent=False, bbox_inches='tight')

The demo above produces the figure below.

Feel free to email the authors with any questions:
Julius Adebayo ([email protected])

Data

The data used for the demo above is available in the repo at: /doc/example_notebooks/propublica_data_for_fairml.csv

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].