
Rebalance a biased tabular dataset by group
Source:R/fairness_gan.R
morie_fairness_ctgan_debiaser.RdA port of the CTGAN-style debiaser from arXiv:2603.18987. Conditions a tabular GAN on (group, outcome) and synthesises rows in which every group's favourable-outcome rate matches the privileged group's, so the Disparate-Impact Ratio of the debiased data moves toward 1.
Usage
morie_fairness_ctgan_debiaser(
df,
outcome_col,
feature_cols,
group_col = "group",
favorable = 1L,
privileged = NULL,
n = 1000L,
steps = 1500L,
seed = 0L
)Arguments
- df
Data.frame with at least the group, outcome and feature columns.
- outcome_col
Binary outcome column (favorable=1 default).
- feature_cols
Character vector of continuous feature columns.
- group_col
Protected-attribute column (default "group").
- favorable
The favourable outcome value (default 1).
- privileged
The group whose favourable rate is targeted.
- n
Number of synthetic rows to return.
- steps
Training iterations in the Python CTGAN; the native debiaser resamples rows rather than training a generator, so this is carried for interface parity and has no effect.
- seed
Sampling/training seed.
Value
morie_fairness_result; $debiased carries the
synthesised data.frame (native base-R resampling: each synthetic row
draws its group from the observed group shares, its outcome at the
privileged group's favourable rate, and its features from an observed
row with that group and outcome).
Examples
df <- data.frame(group = c("A", "B"), outcome = c(1, 0), stringsAsFactors = FALSE)
r <- morie_fairness_ctgan_debiaser(df, outcome_col = "outcome",
feature_cols = c("x1"), group_col = "group", n = 5L)
r$warnings
#> [1] "missing column(s): x1"