aif360.sklearn.inprocessing.SenSR

class aif360.sklearn.inprocessing.SenSR(module, *, criterion, distance_x, eps, lr_lamb, lr_param, auditor_nsteps, auditor_lr, regression='auto', **kwargs)[source]

Sensitive Subspace Robustness (SenSR).

SenSR is an in-processing method for individual fairness which enforces performance invariance under certain sensitive perturbations to the input [1].

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.SenSR) – 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.

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

  • lr_lamb (float) – \(\lambda\) parameter in the SenSR algorithm.

  • lr_param (float) – \(\alpha\) parameter in the SenSR 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, eps, lr_lamb, lr_param, 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.

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

  • lr_lamb (float) – \(\lambda\) parameter in the SenSR algorithm.

  • lr_param (float) – \(\alpha\) parameter in the SenSR 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.