Skip to content

Commit

Permalink
candidate fix for #48
Browse files Browse the repository at this point in the history
  • Loading branch information
pbiecek committed Aug 21, 2022
1 parent 6498abf commit 1e7d1b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# fairmodels 1.2.1
* changed CITATION file (added reference to the RJournal)
* fix for https://github.com/ModelOriented/fairmodels/issues/49
* fix for https://github.com/ModelOriented/fairmodels/issues/48

# fairmodels 1.2.0
* Added filtering metrics when plotting and printing of `fairness_object`.
Expand Down
5 changes: 5 additions & 0 deletions R/resample.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ resample <- function(protected, y, type = "uniform", probs = NULL, cutoff = 0.5)
Xsc <- sum(protected == subgroup & y == actual_class)
# formula for constructing the weights
w_vec[actual_class + 1] <- (Xs * Xc) / (n * Xsc)
# fix for https://github.com/ModelOriented/fairmodels/issues/48
if (is.infinite(w_vec[actual_class + 1])) {
w_vec[actual_class + 1] = 0
warning("Infinite weights, set to 0. Probably sizes of some protected groups are too small")
}
}
num_sc <- append(num_sc, list(num_c))
weight_list <- append(weight_list, list(w_vec))
Expand Down

0 comments on commit 1e7d1b4

Please sign in to comment.