Calculates Statistical Parity ((TP+FP)/(TP+FP+TN+FN)) ratio between privileged and discriminated label for given model, which is one of the most important fairness metrics for us, because it measures how similar the distributions of sensitive values are.
calc_STP(model, test_ds, sensitive, dev)
model | net, nn_module, neural network model we want to evaluate |
---|---|
test_ds |
|
sensitive | numerical vector of sensitive variable |
dev | device used for calculations (cpu or gpu) |
float, STP ratio
if (FALSE) { dev <- "cpu" # presaved torch model model <- torch_load(system.file("extdata","clf2",package="fairpan")) # presaved output of preprocess function processed <- torch_load(system.file("extdata","processed",package="fairpan")) dsl <- dataset_loader(processed$train_x, processed$train_y, processed$test_x, processed$test_y, batch_size = 5, dev = dev) calc_STP(model, dsl$test_ds, processed$sensitive_test, dev) }