class_docstr: Class for computing metrics based on a single
  :obj:`~aif360.datasets.RegressionDataset`.
docstr:     Infeasible Index metric, as described in [1]_.
  
      Args:
          target_prop (dict): desired proportion of groups.
          r (int): size of the candidate list over which the metric is calculated.
          Defaults to the size of the dataset.
      
      Returns:
          A tuple (int, set{int}): InfeasibleIndex and the positions at which the 
          feasibility condition is violated. 
      
  References:
      .. [1] Sahin Cem Geyik, Stuart Ambler, and Krishnaram Kenthapadi,
          "Fairness-Aware Ranking in Search & Recommendation Systems with Application to LinkedIn Talent Search,"
          KDD '19: Proceedings of the 25th ACM SIGKDD International Conference
          on Knowledge Discovery & Data Mining, July 2019, Pages 2221-2231.
      
code: def infeasible_index(self, target_prop: dict, r: int = None):
      """
          Infeasible Index metric, as described in [1]_.
  
          Args:
              target_prop (dict): desired proportion of groups.
              r (int): size of the candidate list over which the metric is calculated.
              Defaults to the size of the dataset.
  
          Returns:
              A tuple (int, set{int}): InfeasibleIndex and the positions at which the
              feasibility condition is violated.
  
      References:
          .. [1] Sahin Cem Geyik, Stuart Ambler, and Krishnaram Kenthapadi,
              "Fairness-Aware Ranking in Search & Recommendation Systems with Application to LinkedIn Talent Search,"
              KDD '19: Proceedings of the 25th ACM SIGKDD International Conference
              on Knowledge Discovery & Data Mining, July 2019, Pages 2221-2231.
      """
      pr_attr_values = np.ravel(
          self.dataset.unprivileged_protected_attributes
          + self.dataset.privileged_protected_attributes
      )
      if set(list(target_prop.keys())) != set(pr_attr_values):
          raise ValueError(
              "Desired proportions must be specified for all values of the protected attributes!"
          )
  
      ranking = np.column_stack(
          (self.dataset.scores, self.dataset.protected_attributes)
      )
      if r is None:
          r = np.ravel(self.dataset.scores).shape[0]
      ii = 0
      k_viol = set()
      for k in range(1, r):
          rk = ranking[:k]
          for ai in pr_attr_values:
              count_ai = rk[rk[:, 1] == ai].shape[0]
              if count_ai < np.floor(target_prop[ai] * k):
                  ii += 1
                  k_viol.add(k - 1)
      return ii, list(k_viol)
  
file_path: AIF360/aif360/metrics/regression_metric.py
imports: import numpy
  from aif360.metrics import DatasetMetric
  from aif360.datasets import RegressionDataset
label_desc: Use image node_id 2 for calling the RegressionDatasetMetric obj's underlying member method code with example usage: obj.infeasible_index(target_prop, r) and returns: ii,  list