Print ceteris paribus cutoff

# S3 method for ceteris_paribus_cutoff
print(x, ...)

Arguments

x

ceteris_paribus_cutoff object

...

other print parameters

Examples


data("german")

german <- german[1:500,]
y_numeric <- as.numeric(german$Risk) -1

lm_model <- glm(Risk~.,
                data = german,
                family=binomial(link="logit"))

rf_model <- ranger::ranger(Risk ~.,
                           data = german,
                           probability = TRUE,
                           num.trees = 200,
                           num.threads = 1)

explainer_lm <- DALEX::explain(lm_model, data = german[,-1], y = y_numeric)
#> Preparation of a new explainer is initiated
#>   -> model label       :  lm  (  default  )
#>   -> data              :  500  rows  9  cols 
#>   -> target variable   :  500  values 
#>   -> predict function  :  yhat.glm  will be used (  default  )
#>   -> predicted values  :  No value for predict function target column. (  default  )
#>   -> model_info        :  package stats , ver. 4.1.0 , task classification (  default  ) 
#>   -> predicted values  :  numerical, min =  0.1320977 , mean =  0.728 , max =  0.9836791  
#>   -> residual function :  difference between y and yhat (  default  )
#>   -> residuals         :  numerical, min =  -0.952954 , mean =  1.222888e-13 , max =  0.7735841  
#>   A new explainer has been created!  
explainer_rf <- DALEX::explain(rf_model, data = german[,-1], y = y_numeric)
#> Preparation of a new explainer is initiated
#>   -> model label       :  ranger  (  default  )
#>   -> data              :  500  rows  9  cols 
#>   -> target variable   :  500  values 
#>   -> predict function  :  yhat.ranger  will be used (  default  )
#>   -> predicted values  :  No value for predict function target column. (  default  )
#>   -> model_info        :  package ranger , ver. 0.12.1 , task classification (  default  ) 
#>   -> predicted values  :  numerical, min =  0.09960516 , mean =  0.7264954 , max =  0.9966667  
#>   -> residual function :  difference between y and yhat (  default  )
#>   -> residuals         :  numerical, min =  -0.7163019 , mean =  0.001504627 , max =  0.5682619  
#>   A new explainer has been created!  

fobject <- fairness_check(explainer_lm, explainer_rf,
                          protected = german$Sex,
                          privileged = "male")
#> Creating fairness classification object
#> -> Privileged subgroup		: character ( Ok  )
#> -> Protected variable		: factor ( Ok  ) 
#> -> Cutoff values for explainers	: 0.5 ( for all subgroups ) 
#> -> Fairness objects		: 0 objects 
#> -> Checking explainers		: 2 in total (  compatible  )
#> -> Metric calculation		: 12/12 metrics calculated for all models
#>  Fairness object created succesfully  

ceteris_paribus_cutoff(fobject, "female")
#> 
#> Ceteribus paribus cutoff for subgroup: female 
#> 
#> First rows from data: 
#>   parity_loss metric cutoff model
#> 1  0.07972347    TPR   0.00    lm
#> 2  0.17350489    PPV   0.00    lm
#> 3  0.40546511    FPR   0.00    lm
#> 4  0.15175891    STP   0.00    lm
#> 5  0.13537101    ACC   0.00    lm
#> 6  0.07972347    TPR   0.01    lm
#> 
#> Minimums: 
#>         model mins
#> lm         lm 0.39
#> ranger ranger 0.50
#>