fairness_pca {fairmodels} | R Documentation |
Fairness PCA
Description
Calculate PC for metric_matrix to see similarities between models and metrics. If omit_models_with_NA
is set to TRUE
models with NA will be omitted as opposed
to default behavior, when metrics are omitted.
Usage
fairness_pca(x, omit_models_with_NA = FALSE)
Arguments
x |
object of class |
omit_models_with_NA |
logical, if |
Value
fairness_pca
object
It is list containing following fields:
pc_1_2 - amount of data variance explained with each component
rotation - rotation from
stats::prcomp
x - x from
stats::prcomp
sdev - sdev from
stats::prcomp
label - model labels
Examples
data("german")
y_numeric <- as.numeric(german$Risk) - 1
lm_model <- glm(Risk ~ .,
data = german,
family = binomial(link = "logit")
)
rf_model <- ranger::ranger(Risk ~ .,
data = german,
probability = TRUE,
num.trees = 200,
num.threads = 1
)
explainer_lm <- DALEX::explain(lm_model, data = german[, -1], y = y_numeric)
explainer_rf <- DALEX::explain(rf_model, data = german[, -1], y = y_numeric)
fobject <- fairness_check(explainer_lm, explainer_rf,
protected = german$Sex,
privileged = "male"
)
# same explainers with different cutoffs for female
fobject <- fairness_check(explainer_lm, explainer_rf, fobject,
protected = german$Sex,
privileged = "male",
cutoff = list(female = 0.4),
label = c("lm_2", "rf_2")
)
fpca <- fairness_pca(fobject)
plot(fpca)
[Package fairmodels version 1.2.1 Index]