Fair Twin Inspection convenience function.

fairTwins(x, train.id = seq_len(nrow(x$train)), test.id = NULL, cols = NULL)

Arguments

x

Object of class fairadapt, a result of an adaptation procedure.

train.id

A vector of indices specifying which rows of the training data should be displayed.

test.id

A vector of indices specifying which rows of the test data should be displayed.

cols

A character vector, subset of names(train.data), which specifies which subset of columns is to be displayed in the result.

Value

A data.frame, containing the original and adapted values of the requested individuals. Adapted columns have _adapted appended to their original name.

Examples

n_samp <- 200
uni_dim <- c(       "gender", "edu", "test", "score")
uni_adj <- matrix(c(       0,     1,      1,       0,
                           0,     0,      1,       1,
                           0,     0,      0,       1,
                           0,     0,      0,       0),
                  ncol = length(uni_dim),
                  dimnames = rep(list(uni_dim), 2),
                  byrow = TRUE)

uni_ada <- fairadapt(score ~ .,
  train.data = head(uni_admission, n = n_samp),
  test.data = tail(uni_admission, n = n_samp),
  adj.mat = uni_adj,
  prot.attr = "gender"
)

fairTwins(uni_ada, train.id = 1:5)
#>   gender      score score_adapted        edu edu_adapted         test
#> 1      1  1.9501728   1.934820828  1.3499572  0.79948061  1.617739679
#> 2      0 -2.3502495  -2.350249546 -1.9779234 -1.97792341 -3.121796235
#> 3      1  0.6285619   0.001971122  0.6263626  0.01456239  0.530034686
#> 4      1  0.7064857   0.277094270  0.8142112 -0.03731391  0.004573003
#> 5      1  0.3678313   0.296845743  1.8415242  0.87755417  1.193677123
#>   test_adapted
#> 1  1.169657867
#> 2 -3.121796235
#> 3 -0.004056565
#> 4 -0.829381258
#> 5  0.544826681