
Ceteris-paribus profile for one instance
Source:R/fairness_xai.R
morie_fairness_xai_ceteris_paribus.RdHolds 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
)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.