h2o.fair_shap_plot: SHAP summary plot for one feature with protected groups on...

h2o.fair_shap_plotR Documentation

SHAP summary plot for one feature with protected groups on y-axis.

Description

SHAP summary plot for one feature with protected groups on y-axis.

Usage

h2o.fair_shap_plot(model, newdata, protected_columns, column, autoscale = TRUE)

Arguments

model

H2O Model Object

newdata

H2OFrame

protected_columns

List of categorical columns that contain sensitive information such as race, gender, age etc.

column

String containing column name.

autoscale

If TRUE, try to guess when to use log transformation on X axis.

Value

list of ggplot2 objects

Examples

## Not run: 
library(h2o)
h2o.init()
data <- h2o.importFile(paste0("https://s3.amazonaws.com/h2o-public-test-data/smalldata/",
                              "admissibleml_test/taiwan_credit_card_uci.csv"))
x <- c('LIMIT_BAL', 'AGE', 'PAY_0', 'PAY_2', 'PAY_3', 'PAY_4', 'PAY_5', 'PAY_6', 'BILL_AMT1',
       'BILL_AMT2', 'BILL_AMT3', 'BILL_AMT4', 'BILL_AMT5', 'BILL_AMT6', 'PAY_AMT1', 'PAY_AMT2',
       'PAY_AMT3', 'PAY_AMT4', 'PAY_AMT5', 'PAY_AMT6')
y <- "default payment next month"
protected_columns <- c('SEX', 'EDUCATION')

for (col in c(y, protected_columns))
  data[[col]] <- as.factor(data[[col]])

splits <- h2o.splitFrame(data, 0.8)
train <- splits[[1]]
test <- splits[[2]]
reference <- c(SEX = "1", EDUCATION = "2")  # university educated man
favorable_class <- "0" # no default next month

gbm <- h2o.gbm(x, y, training_frame = train)

h2o.fair_shap_plot(gbm, test, protected_columns, "AGE")

## End(Not run)


h2o documentation built on Aug. 9, 2023, 9:06 a.m.