Skip to content

Commit 1e7d1b4

Browse files
committed
candidate fix for #48
1 parent 6498abf commit 1e7d1b4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# fairmodels 1.2.1
22
* changed CITATION file (added reference to the RJournal)
33
* fix for https://github.com/ModelOriented/fairmodels/issues/49
4+
* fix for https://github.com/ModelOriented/fairmodels/issues/48
45

56
# fairmodels 1.2.0
67
* Added filtering metrics when plotting and printing of `fairness_object`.

R/resample.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ resample <- function(protected, y, type = "uniform", probs = NULL, cutoff = 0.5)
127127
Xsc <- sum(protected == subgroup & y == actual_class)
128128
# formula for constructing the weights
129129
w_vec[actual_class + 1] <- (Xs * Xc) / (n * Xsc)
130+
# fix for https://github.com/ModelOriented/fairmodels/issues/48
131+
if (is.infinite(w_vec[actual_class + 1])) {
132+
w_vec[actual_class + 1] = 0
133+
warning("Infinite weights, set to 0. Probably sizes of some protected groups are too small")
134+
}
130135
}
131136
num_sc <- append(num_sc, list(num_c))
132137
weight_list <- append(weight_list, list(w_vec))

0 commit comments

Comments
 (0)