Skip to contents

Holds every feature of x fixed except feature, sweeps it across the range observed in X_ref, and reports the resulting prediction profile.

Usage

morie_fairness_xai_ceteris_paribus(
  predict_fn,
  x,
  feature,
  X_ref,
  feature_names = NULL,
  grid_size = 20L
)

Arguments

predict_fn

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

x

Numeric vector of length d (the instance).

feature

Index or name of the feature to vary.

X_ref

Reference matrix used for the feature range.

feature_names

Optional character vector.

grid_size

Number of grid points.

Value

morie_fairness_result; $value is the profile's swing (max - min).

Examples

set.seed(9)
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_ceteris_paribus(predict_fn, X[1L, ], feature = "f1",
  X_ref = X, feature_names = colnames(X), grid_size = 8L)
#> Ceteris-Paribus Profile — f1
#> ============================
#>   Feature              f1
#>   Instance prediction  -1.5581
#>   Profile swing        7.9495
#> 
#> Holding this instance fixed and varying 'f1' alone, the prediction swings by 7.9495. A large swing on a protected feature means the decision would change purely on that characteristic.