calc_STP: Calculates STP ratio

Description Usage Arguments Value Examples

View source: R/evaluate.R

Description

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.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
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)

## End(Not run)

ModelOriented/FairPAN documentation built on Dec. 17, 2021, 4:19 a.m.