ModelOriented / fairmodels

Flexible tool for bias detection, visualization, and mitigation
https://fairmodels.drwhy.ai/
GNU General Public License v3.0
85 stars 15 forks source link

all_cutoffs parity loss #24

Closed Locust2520 closed 3 years ago

Locust2520 commented 3 years ago

In the all_cutoffs function we can read:

      # like in create fobject
      gmm             <- calculate_group_fairness_metrics(group_matrices)
      gmm_scaled      <- abs(apply(gmm, 2 , function(x) x  - gmm[,privileged]))
      gmm_loss        <- rowSums(gmm_scaled)

but the parity loss in fairness_check is computed this way:

    # group metric matrix
    gmm <- calculate_group_fairness_metrics(group_matrices)

    # from every column in matrix subtract base column, then get abs value
    # in other words we measure distance between base group
    # metrics score and other groups metric scores

    gmm_scaled      <- apply(gmm, 2 , function(x) x  / gmm[, privileged])
    gmm_abs         <- apply(gmm_scaled, 2 , function(x) sapply(x, function(y) abs(log(y))))
    gmm_loss        <- rowSums(gmm_abs)

Why is the loss function not the same?

jakwisn commented 3 years ago

Hi, thanks for the issue. You are right, in both all_cutoffs and ceteris_paribus_cutoff the so-called "parity_loss" should be computed like in fairness_check.