classification_metric: Classification Metric

Description Usage Arguments See Also Examples

View source: R/classification_metric.R

Description

Class for computing metrics based on two BinaryLabelDatasets. The first dataset is the original one and the second is the output of the classification transformer (or similar)

Usage

1
classification_metric(dataset, classified_dataset, unprivileged_groups, privileged_groups)

Arguments

dataset

(BinaryLabelDataset) Dataset containing ground-truth labels

classified_dataset

(BinaryLabelDataset) Dataset containing predictions

unprivileged_groups

Unprivileged groups. List containing unprivileged protected attribute name and value of the unprivileged protected attribute.

privileged_groups

Privileged groups. List containing privileged protected attribute name and value of the privileged protected attribute.

See Also

Explore available classification metrics explanations here

Available metrics:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
load_aif360_lib()
# Input dataset
data <- data.frame("feat" = c(0,0,1,1,1,1,0,1,1,0), "label" = c(1,0,0,1,0,0,1,0,1,1))
# Create aif compatible input dataset
act <- aif360::aif_dataset(data_path = data,  favor_label=0, unfavor_label=1,
                            unprivileged_protected_attribute=0,
                            privileged_protected_attribute=1,
                            target_column="label", protected_attribute="feat")
# Classified dataset
pred_data <- data.frame("feat" = c(0,0,1,1,1,1,0,1,1,0), "label" = c(1,0,1,1,1,0,1,0,0,1))
# Create aif compatible classified dataset
pred <- aif360::aif_dataset(data_path = pred_data,  favor_label=0, unfavor_label=1,
                             unprivileged_protected_attribute=0,
                             privileged_protected_attribute=1,
                             target_column="label", protected_attribute="feat")
# Create an instance of classification metric
cm <- classification_metric(act, pred, list('feat', 1), list('feat', 0))
# Access metric functions
cm$accuracy()

aif360 documentation built on July 1, 2020, 5:34 p.m.