inFairness.fairalgo.senstir module#

class inFairness.fairalgo.senstir.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]#

Bases: Module

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:
Returns:

output – Model output

Return type:

torch.Tensor

forward_test(Q)[source]#

Forward method during the test phase

forward_train(Q, relevances)[source]#
training: bool#