fair_seldonian.data package#

Submodules#

fair_seldonian.data.synthetic module#

fair_seldonian.data.synthetic.data_split(frac, all_data, random_state, m_test)[source]#
Parameters:
Return type:

tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray]

fair_seldonian.data.synthetic.get_data(
N,
features,
t_ratio,
tp0_ratio,
tp1_ratio,
random_seed,
signal_noise=0.5,
include_sensitive_feature=True,
)[source]#

Synthetic binary-classification data with a base-rate gap between groups.

T ~ Bernoulli(t_ratio) selects the group; the label is then drawn with P(Y=1 | T=0) = tp0_ratio and P(Y=1 | T=1) = tp1_ratio. The gap between those two base rates is what makes the fairness constraint bite.

The signal feature is Y + N(0, signal_noise), giving a Bayes error of Phi(-1 / (2 * signal_noise)). Additive noise is essential: a construction like Y * uniform(0, 1) is zero exactly when Y = 0 and positive otherwise, so the label is perfectly recoverable, the Bayes error is zero, and there is no accuracy-fairness frontier to trade along - any loss the constrained model paid would be an artifact rather than a real cost.

Parameters:
  • N (int) – number of samples.

  • features (int) – total number of columns in the returned feature block, including the sensitive column when include_sensitive_feature is set.

  • t_ratio (float) – P(T = 1).

  • tp0_ratio (float) – P(Y = 1 | T = 0).

  • tp1_ratio (float) – P(Y = 1 | T = 1).

  • random_seed (float) – seed; distinct values give independent datasets.

  • signal_noise (float) – standard deviation of the label noise in the signal feature.

  • include_sensitive_feature (bool) – whether T is also supplied to the model as an input feature (“fairness through awareness”). Explicit because it materially changes the problem: with T available the classifier can condition directly on group membership. Easy to leave unstated, too, since appending T to the feature block survives the column slicing in data_split() without comment.

Returns:

frame of features + 2 columns - the feature block, then Y, then T.

Return type:

DataFrame

Module contents#