Skip to contents

Partial dependence on one feature (Friedman)

Usage

morie_fairness_xai_partial_dependence(
  predict_fn,
  X,
  feature,
  feature_names = NULL,
  grid_size = 20L
)

Arguments

predict_fn

Function mapping an (n, d) matrix to n numeric predictions.

X

Numeric matrix or data.frame.

feature

Index or name of the feature to sweep.

feature_names

Optional character vector.

grid_size

Number of grid points.

Value

morie_fairness_result; $value is the PD range.

Examples

set.seed(4)
X <- matrix(rnorm(400), 100, 4); colnames(X) <- paste0("f", 1:4)
predict_fn <- function(M) as.numeric(M %*% c(1.5, -0.7, 0, 0.3))
morie_fairness_xai_partial_dependence(predict_fn, X, feature = "f1",
  feature_names = colnames(X), grid_size = 10L)
#> Partial Dependence — f1
#> =======================
#>   Feature    f1
#>   PD range   6.1916
#>   PD at min  -2.6657
#>   PD at max  3.5258
#> 
#> As 'f1' sweeps its observed range, the model's average prediction moves over a span of 6.1916.