Skip to contents

First-order Accumulated Local Effects (Apley & Zhu)

Usage

morie_fairness_xai_ale(
  predict_fn,
  X,
  feature,
  feature_names = NULL,
  n_bins = 10L
)

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.

n_bins

Number of quantile bins.

Value

morie_fairness_result; $value is the ALE range.

Examples

set.seed(7)
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_ale(predict_fn, X, feature = "f2",
  feature_names = colnames(X), n_bins = 5L)
#> Accumulated Local Effects — f2
#> ==============================
#>   Feature    f2
#>   Bins       5
#>   ALE range  3.267
#> 
#> The accumulated local effect of 'f2' spans 3.2670 across its range, correlation-robustly.