aif360.sklearn.inprocessing.SenSeI

class aif360.sklearn.inprocessing.SenSeI(module, *, criterion, distance_x, distance_y, rho, eps, auditor_nsteps, auditor_lr, regression='auto', **kwargs)[source]

Sensitive Set Invariance (SenSeI).

SenSeI is an in-processing method for individual fairness [1]. In this method, individual fairness is formulated as invariance on certain sensitive sets. SenSeI minimizes a transport-based regularizer that enforces this version of individual fairness.

References

Variables:
  • regression_ (bool) – Whether or not this task is treated as regression.

  • classes_ (array, shape (n_classes,)) – A list of class labels known to the transformer. Only present if self.regression_ is False and y is provided to fit.

  • module_ (inFairness.fairalgo.SenSeI) – The fair PyTorch module.

Parameters:
  • module (torch.nn.Module) – Network architecture.

  • criterion (torch.nn.Module) – Loss function.

  • distance_x (inFairness.distances.Distance) – Distance metric in the input space.

  • distance_y (inFairness.distances.Distance) – Distance metric in the output space.

  • rho (float) – \(\rho\) parameter in the SenSeI algorithm.

  • eps (float) – \(\epsilon\) parameter in the SenSeI algorithm.

  • auditor_nsteps (int) – Number of update steps for the auditor to find worst-case examples

  • auditor_lr (float) – Learning rate for the auditor.

  • regression (bool or 'auto') – Task is regression. If ‘auto’, this is inferred using sklearn.utils.multiclass.type_of_target() on y in fit(). If a Dataset is provided to fit, this defaults to False. If y contains ‘soft’ targets (i.e. probabilities per class), this should be manually set to False.

  • train_split (callable, optional) – See skorch.net.NeuralNet. Note: validation loss does not include any fairness loss, only the provided criterion, and should not be used for early stopping, etc. Default is None (no split).

  • **kwargs – See skorch.net.NeuralNet.

Methods

evaluation_step

Perform a forward step to produce the output used for prediction and scoring.

fit

Initialize and fit the model.

get_loss

Return the loss for this batch.

initialize_module

Initializes the module.

predict

Return class labels for samples in X if task is classification or predicted values if task is regression.

train_step_single

Compute y_pred, loss value, and update net's gradients.

validation_step

Perform a forward step using batched data and return the resulting loss.

__init__(module, *, criterion, distance_x, distance_y, rho, eps, auditor_nsteps, auditor_lr, regression='auto', **kwargs)[source]
Parameters:
  • module (torch.nn.Module) – Network architecture.

  • criterion (torch.nn.Module) – Loss function.

  • distance_x (inFairness.distances.Distance) – Distance metric in the input space.

  • distance_y (inFairness.distances.Distance) – Distance metric in the output space.

  • rho (float) – \(\rho\) parameter in the SenSeI algorithm.

  • eps (float) – \(\epsilon\) parameter in the SenSeI algorithm.

  • auditor_nsteps (int) – Number of update steps for the auditor to find worst-case examples

  • auditor_lr (float) – Learning rate for the auditor.

  • regression (bool or 'auto') – Task is regression. If ‘auto’, this is inferred using sklearn.utils.multiclass.type_of_target() on y in fit(). If a Dataset is provided to fit, this defaults to False. If y contains ‘soft’ targets (i.e. probabilities per class), this should be manually set to False.

  • train_split (callable, optional) – See skorch.net.NeuralNet. Note: validation loss does not include any fairness loss, only the provided criterion, and should not be used for early stopping, etc. Default is None (no split).

  • **kwargs – See skorch.net.NeuralNet.

initialize_module()[source]

Initializes the module.

If the module is already initialized and no parameter was changed, it will be left as is.