Skip to main content

Fairnes checker

Project description

Fairness Checker

This Python module fairness_checker provides a set of methods to evaluate the fairness of a predictive model's outcomes across different demographic groups represented in a CSV file or given a model.

Dependencies

  • Python >= 3.6

Installation

pip3 install fairness-checker

Usage

For example:

from fairness_checker import fairness_csv_checker
c = fairness_csv_checker("compas-scores-two-years.csv")
c.demographic_parity(0.2, lambda row: row['sex'] == 'Male', lambda row: row['score_text'] in {'Medium', 'High'})

Output:

demographic parity
fair: 0.04 < 0.2

Note the function signature of demographic_parity:

demographic_parity(ratio: float,
                   privileged_predicate: Callable[[csv_row], bool],
                   positive_predicate: Callable[[T], bool]) -> bool:

Here the privileged_predicate is

lambda row: row['sex'] == 'Male'

meaning the privileged group is the male group, and the positive_predicate is

lambda row: row['score_text'] in {'Medium', 'High'}

meaning the row is positive if the score is categorized as medium or high.

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

fairness_checker-0.0.41.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

fairness_checker-0.0.41-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

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