inFairness.distances.explore_distance module#
- class inFairness.distances.explore_distance.EXPLOREDistance[source]#
Bases:
MahalanobisDistances
Implements the Embedded Xenial Pairs Logistic Regression metric (EXPLORE) defined in Section 2.2 of Two Simple Ways to Learn Individual Fairness Metrics from Data.
EXPLORE defines the distance in the input space to be of the form:
where
is an embedding map and is a semi-positive definite matrix.The metric expects the data to be in the form of triplets
where indicates whether the human considers and comparable ( indicates comparable) or not.References
Mukherjee, Debarghya, Mikhail Yurochkin, Moulinath Banerjee, and Yuekai Sun. “Two simple ways to learn individual fairness metrics from data.” In International Conference on Machine Learning, pp. 7097-7107. PMLR, 2020.
- fit(X1, X2, Y, iters, batchsize, autoinfer_device=True)[source]#
Fit EXPLORE distance metric
- Parameters:
X1 (torch.Tensor) – first set of input samples
X2 (torch.Tensor) – second set of input samples
Y (torch.Tensor) –
vector containing 1 if corresponding elements from X1 and X2 are comparable, and 0 if notiters (int) – number of iterations of SGD to compute the
matrixbatchsize (int) – batch size of each iteration
autoinfer_device (bool) – Should the distance metric be automatically moved to an appropriate device (CPU / GPU) or not? If set to True, it moves the metric to the same device X1 is on. If set to False, keeps the metric on CPU.
- training: bool#