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)

Arguments

model

net, nn_module, neural network model we want to evaluate

test_ds

dataset object from torch used for making predictions for STP ratio

sensitive

numerical vector of sensitive variable

dev

device used for calculations (cpu or gpu)

Value

float, STP ratio

Examples

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) }