class_docstr: Class for computing metrics based on a single
  :obj:`~aif360.datasets.BinaryLabelDataset`.
class_docstr_tok: ["Class","for","computing","metrics","based","on","a","single",":","obj",":","`","~aif360.datasets.BinaryLabelDataset","`","."]
docstr: Smoothed EDF from [#foulds18]_.
  
  Args:
      concentration (float, optional): Concentration parameter for
          Dirichlet smoothing. Must be non-negative.
  
  Examples:
      To use with non-binary protected attributes, the column must be
      converted to ordinal:
  
      >>> mapping = {'Black': 0, 'White': 1, 'Asian-Pac-Islander': 2,
      ... 'Amer-Indian-Eskimo': 3, 'Other': 4}
      >>> def map_race(df):
      ...     df['race-num'] = df.race.map(mapping)
      ...     return df
      ...
      >>> adult = AdultDataset(protected_attribute_names=['sex',
      ... 'race-num'], privileged_classes=[['Male'], [1]],
      ... categorical_features=['workclass', 'education',
      ... 'marital-status', 'occupation', 'relationship',
      ... 'native-country', 'race'], custom_preprocessing=map_race)
      >>> metric = BinaryLabelDatasetMetric(adult)
      >>> metric.smoothed_empirical_differential_fairness()
      1.7547611985549287
  
  References:
      .. [#foulds18] J. R. Foulds, R. Islam, K. N. Keya, and S. Pan,
         "An Intersectional Definition of Fairness," arXiv preprint
         arXiv:1807.08362, 2018.
docstr_tok: ["Smoothed","EDF","from","[","#","foulds18","]","_.","Args",":","concentration","(","float",",","optional",")",":","Concentration","parameter","for","Dirichlet","smoothing",".","Must","be","non-negative",".","Examples",":","To","use","with","non-binary","protected","attributes",",","the","column","must","be","converted","to","ordinal",":",">",">",">","mapping","=","{","'Black","'",":","0",",","'White","'",":","1",",","'Asian-Pac-Islander","'",":","2",",","...","'Amer-Indian-Eskimo","'",":","3",",","'Other","'",":","4","}",">",">",">","def","map_race","(","df",")",":","...","df","[","'race-num","'","]","=","df.race.map","(","mapping",")","...","return","df","...",">",">",">","adult","=","AdultDataset","(","protected_attribute_names=","[","'sex","'",",","...","'race-num","'","]",",","privileged_classes=","[","[","'Male","'","]",",","[","1","]","]",",","...","categorical_features=","[","'workclass","'",",","'education","'",",","...","'marital-status","'",",","'occupation","'",",","'relationship","'",",","...","'native-country","'",",","'race","'","]",",","custom_preprocessing=map_race",")",">",">",">","metric","=","BinaryLabelDatasetMetric","(","adult",")",">",">",">","metric.smoothed_empirical_differential_fairness","(",")","1.7547611985549287","References",":","..","[","#","foulds18","]","J.","R.","Foulds",",","R.","Islam",",","K.","N.","Keya",",","and","S.","Pan",",","``","An","Intersectional","Definition","of","Fairness",",","''","arXiv","preprint","arXiv:1807.08362",",","2018","."]
code: def smoothed_empirical_differential_fairness(self, concentration=1.0):
      """Smoothed EDF from [#foulds18]_.
  
      Args:
          concentration (float, optional): Concentration parameter for
              Dirichlet smoothing. Must be non-negative.
  
      Examples:
          To use with non-binary protected attributes, the column must be
          converted to ordinal:
  
          >>> mapping = {'Black': 0, 'White': 1, 'Asian-Pac-Islander': 2,
          ... 'Amer-Indian-Eskimo': 3, 'Other': 4}
          >>> def map_race(df):
          ...     df['race-num'] = df.race.map(mapping)
          ...     return df
          ...
          >>> adult = AdultDataset(protected_attribute_names=['sex',
          ... 'race-num'], privileged_classes=[['Male'], [1]],
          ... categorical_features=['workclass', 'education',
          ... 'marital-status', 'occupation', 'relationship',
          ... 'native-country', 'race'], custom_preprocessing=map_race)
          >>> metric = BinaryLabelDatasetMetric(adult)
          >>> metric.smoothed_empirical_differential_fairness()
          1.7547611985549287
  
      References:
          .. [#foulds18] J. R. Foulds, R. Islam, K. N. Keya, and S. Pan,
             "An Intersectional Definition of Fairness," arXiv preprint
             arXiv:1807.08362, 2018.
      """
      sbr = self._smoothed_base_rates(
          self.dataset.labels, concentration
      )
  
      def pos_ratio(i, j):
          return abs(np.log(sbr[i]) - np.log(sbr[j]))
  
      def neg_ratio(i, j):
          return abs(np.log(1 - sbr[i]) - np.log(1 - sbr[j]))
  
      # overall DF of the mechanism
      return max(
          max(pos_ratio(i, j), neg_ratio(i, j))
          for i in range(len(sbr))
          for j in range(len(sbr))
          if i != j
      )
  
imports: import numpy
  from sklearn.neighbors import NearestNeighbors
  from aif360.algorithms.inprocessing.gerryfair.auditor import Auditor
  from aif360.datasets import BinaryLabelDataset
  from aif360.datasets.multiclass_label_dataset import MulticlassLabelDataset
  from aif360.metrics import DatasetMetric, utils
  from aif360.algorithms.inprocessing.gerryfair.clean import *
label_desc: Use image node_id 9 for calling the BinaryLabelDatasetMetric obj's underlying member method code with example usage: obj.smoothed_empirical_differential_fairness(concentration) and returns: max, abs, abs