Algorithms#
SenSR: Sensitive Subspace Robustness#
- class inFairness.fairalgo.SenSR(network, distance_x, loss_fn, eps, lr_lamb, lr_param, auditor_nsteps, auditor_lr)[source]#
Implementes the Sensitive Subspace Robustness (SenSR) algorithm.
Proposed in Training individually fair ML models with sensitive subspace robustness
- Parameters:
network (torch.nn.Module) – Network architecture
distance_x (inFairness.distances.Distance) – Distance metric in the input space
loss_fn (torch.nn.Module) – Loss function
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
- forward(X, Y=None, *args, **kwargs)[source]#
Defines the computation performed at every call.
- Parameters:
X (torch.Tensor) – Input data
Y (torch.Tensor) – Expected output data
- Returns:
output – Model output
- Return type:
SenSeI: Sensitive Set Invariance#
- class inFairness.fairalgo.SenSeI(network, distance_x, distance_y, loss_fn, rho, eps, auditor_nsteps, auditor_lr)[source]#
Implementes the Sensitive Set Invariane (SenSeI) algorithm.
Proposed in SenSeI: Sensitive Set Invariance for Enforcing Individual Fairness
- Parameters:
network (torch.nn.Module) – Network architecture
distance_x (inFairness.distances.Distance) – Distance metric in the input space
distance_y (inFairness.distances.Distance) – Distance metric in the output space
loss_fn (torch.nn.Module) – Loss function
rho (float) – \(\rho\) parameter in the SenSR algorithm
eps (float) – \(\epsilon\) 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
- forward(X, Y=None, *args, **kwargs)[source]#
Defines the computation performed at every call.
- Parameters:
X (torch.Tensor) – Input data
Y (torch.Tensor) – Expected output data
- Returns:
output – Model output
- Return type:
SenSTIR: Sensitive Set Transport Invariant Ranking#
- class inFairness.fairalgo.SenSTIR(network: Module, distance_x: MahalanobisDistances, distance_y: MahalanobisDistances, rho: float, eps: float, auditor_nsteps: int, auditor_lr: float, monte_carlo_samples_ndcg: int)[source]#
Implementes the Sensitive Subspace Robustness (SenSR) algorithm.
Proposed in Individually Fair Ranking
- Parameters:
network (torch.nn.Module) – Network architecture
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 SenSTIR algorithm (see Algorithm 1)
eps (float) – \(\epsilon\) parameter in the SenSTIR algorithm (see Algorithm 1)
auditor_nsteps (int) – Number of update steps for the auditor to find worst-case examples
auditor_lr (float) – Learning rate for the auditor
monte_carlo_samples_ndcg (int) – Number of monte carlo samples required to estimate the gradient of the empirical version of expectation defined in equation SenSTIR in the reference
- forward(Q, relevances, **kwargs)[source]#
Defines the computation performed at every call.
- Parameters:
X (torch.Tensor) – Input data
Y (torch.Tensor) – Expected output data
- Returns:
output – Model output
- Return type: