fairadapt | R Documentation |
Implementation of fair data adaptation with quantile preservation
(Plecko & Meinshausen 2019). Uses only plain R
.
fairadapt(
formula,
prot.attr,
adj.mat,
train.data,
test.data = NULL,
cfd.mat = NULL,
top.ord = NULL,
res.vars = NULL,
quant.method = rangerQuants,
visualize.graph = FALSE,
eval.qfit = NULL,
...
)
formula |
Object of class |
prot.attr |
A value of class |
adj.mat |
Matrix of class |
train.data, test.data |
Training data & testing data, both of class
|
cfd.mat |
Symmetric matrix of class |
top.ord |
A vector of class |
res.vars |
A vector of class |
quant.method |
A function choosing the method used for quantile
regression. Default value is |
visualize.graph |
A |
eval.qfit |
Argument indicating whether the quality of the quantile
regression fit should be computed using cross-validation. Default value is
|
... |
Additional arguments forwarded to the function passed as
|
The procedure takes the training and testing data as an input, together with the causal graph given by an adjacency matrix and the list of resolving variables, which should be kept fixed during the adaptation procedure. The procedure then calculates a fair representation of the data, after which any classification method can be used. There are, however, several valid training options yielding fair predictions, and the best of them can be chosen with cross-validation. For more details we refer the user to the original paper. Most of the running time is due to the quantile regression step using the ranger package.
An object of class fairadapt
, containing the original and
adapted training and testing data, together with the causal graph and some
additional meta-information.
Plecko, D. & Meinshausen, N. (2019). Fair Data Adaptation with Quantile Preservation
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"
)
uni_ada
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.