Code Monkey home page Code Monkey logo

cfa's Introduction

The R-package faircause can be used for performing Causal Fairness Analysis and implements the methods described in the paper Causal Fairness Analysis (Plecko & Bareinboim, 2024). We refer you to the manuscript for full theoretical details. In this repository, you will find a range of examples that demonstrate how to use Causal Fairness Analysis in practice.

Suggested Citation

To cite the paper, please use the following:

@article{plecko2024CFA,
  title={Causal Fairness Analysis: A Causal Toolkit for Fair Machine Learning},
  author={Ple{\v{c}}ko, Drago and Bareinboim, Elias},
  journal={Foundations and Trends{\textregistered} in Machine Learning},
  volume={17},
  number={3},
  pages={304--589},
  year={2024},
  publisher={Now Publishers, Inc.}
}

Installation

You can install faircause from this Github repository by using the devtools package:

devtools::install_github("dplecko/CFA")

Please note that faircause is still under development (currently in version 0.2.0) and any debug reports or suggested fixes are welcome.

How to use CFA

A number of vignettes demonstrating how to use the package can be found on our Github pages.

Want to learn more about Causal Fairness Analysis?

For those interested in learning more about CFA, we suggest the following resources:

  1. Reading the Causal Fairness Analysis paper, found here,
  2. Follow the series of lectures on CFA which were part of the COMSW-4775 course at Columbia Computer Science,
  3. Check our ICML 2022 Tutorial.
  4. Check the vignettes on Github pages that demonstrate how to perform Causal Fairness Analysis in practice.

cfa's People

Contributors

dplecko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

j-r-paul w1etse

cfa's Issues

Data table input causes issue for fairness_cookbook()

data <- get(data("gov_census", package = "faircause"))[seq_len(5)]
mdata <- get_metadata("census")
mdata
fc_census <- fairness_cookbook(data, X = mdata$X, Z = mdata$Z, W = mdata$W,
                               Y = mdata$Y, x0 = mdata$x0, x1 = mdata$x1)

The signs of expse_x0 and expse_x1 seems to be flipped

The signs of expse_x0 and expse_x1 seem to be flipped, I calculated TV using the TV decomposition 1 provided in your slides, but the answer doesn't match up with the actual TV. However, the answer does match up if I flip the signs of expse_x0 and expse_x1. Could you take a look at this, please?

library(faircause)
library(ggspectra)

census <- head(faircause::gov_census, n = 20000L)
TV <- mean(census$salary[census$sex == "male"]) -
  mean(census$salary[census$sex == "female"])

X <- "sex" # protected attribute
Z <- c("age", "race", "hispanic_origin", "citizenship", "nativity", 
       "economic_region") # confounders
W <- c("marital", "family_size", "children", "education_level", "english_level", 
       "hours_worked", "weeks_worked", "occupation", "industry") # mediators
Y <- "salary" # outcome

# decompose the total variation measure
set.seed(2022)
tvd <- fairness_cookbook(data = census, X = X, W = W, Z = Z, Y = Y, 
                         x0 = "female", x1 = "male")

expse_x1=mean(tvd$measures$value[tvd$measures$measure == "expse_x1"])
expse_0=mean(tvd$measures$value[tvd$measures$measure == "expse_x0"])
nde=mean(tvd$measures$value[tvd$measures$measure == "nde"])
nie=mean(tvd$measures$value[tvd$measures$measure == "nie"])
tv=mean(tvd$measures$value[tvd$measures$measure == "tv"])
print(paste("Tv Decomposition 1: nde - nie - (expse_x1 - expse_0)", nde - nie - (expse_x1 - expse_0), sep=":"))
print(paste("Actual TV", tv, sep = ":"))
print(paste("Tv Decomposition 1 with flipped signs: nde - nie + (expse_x1 - expse_0)", nde - nie + (expse_x1 - expse_0), sep=":"))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.