aif360.sklearn.metrics.consistency_score

aif360.sklearn.metrics.consistency_score(X, y, n_neighbors=5)[source]

Compute the consistency score.

Individual fairness metric from [1] that measures how similar the labels are for similar instances.

\[1 - \frac{1}{n}\sum_{i=1}^n |\hat{y}_i - \frac{1}{\text{n_neighbors}} \sum_{j\in\mathcal{N}_{\text{n_neighbors}}(x_i)} \hat{y}_j|\]
Parameters:
  • X (array-like) – Sample features.

  • y (array-like) – Sample targets.

  • n_neighbors (int, optional) – Number of neighbors for the knn computation.

References