A library that implements fairness-aware machine learning algorithms

Documentation Status Gitter

themis-ml is a Python library built on top of pandas and sklearnthat implements fairness-aware machine learning algorithms.

themis-ml defines discrimination as the preference (bias) for or against a set of social groups that result in the unfair treatment of its members with respect to some outcome.

It defines fairness as the inverse of discrimination, and in the context of a machine learning algorithm, this is measured by the degree to which the algorithm’s predictions favor one social group over another in relation to an outcome that holds socioeconomic, political, or legal importance, e.g. the denial/approval of a loan application.

A “fair” algorithm depends on how we define fairness. For example if we define fairness as statistical parity, a fair algorithm is one in which the proportion of approved loans among minorities is equal to the proportion of approved loans among white people.

Here are a few of the discrimination discovery and fairness-aware techniques that this library implements.

Measuring Discrimination

  • Mean difference
  • Normalized mean difference
  • Consistency
  • Situation Test Score

Mitigating Discrimination


  • Relabelling (Massaging)
  • Reweighting
  • Sampling

Model Estimation

  • Additive Counterfactually Fair Estimator
  • Prejudice Remover Regularized Estimator


  • Reject Option Classification
  • Discrimination-aware Ensemble Classification


themis-ml also provides utility functions for loading freely available datasets from a variety of sources.

The source code is currently hosted on GitHub: You can install the latest released version with conda or pip.

# conda
conda install -c cosmicbboy themis-ml

If you install with pip, you’ll need to install scikit-learn, numpy, and pandas with either pip or conda. Version requirements:

  • numpy (>= 1.9.0)
  • scikit-learn (>= 0.19.1)
  • pandas (>= 0.22.0)
# pip
pip install themis-ml

Official documentation for this package can be found here

You can find a complete set of references for the discrimination discovery and fairness-aware methods implemented in themis-ml in this paper.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

GIPHY App Key not set. Please check settings

Spring Data — Transactional Caveats

Chandigarh Dropouts Lyrics — Raj Brar