class_docstr: Base class for all structured datasets.
  
  A StructuredDataset requires data to be stored in :obj:`numpy.ndarray`
  objects with :obj:`~numpy.dtype` as :obj:`~numpy.float64`.
  
  Attributes:
      features (numpy.ndarray): Dataset features for each instance.
      labels (numpy.ndarray): Generic label corresponding to each instance
          (could be ground-truth, predicted, cluster assignments, etc.).
      scores (numpy.ndarray): Probability score associated with each label.
          Same shape as `labels`. Only valid for binary labels (this includes
          one-hot categorical labels as well).
      protected_attributes (numpy.ndarray): A subset of `features` for which
          fairness is desired.
      feature_names (list(str)): Names describing each dataset feature.
      label_names (list(str)): Names describing each label.
      protected_attribute_names (list(str)): A subset of `feature_names`
          corresponding to `protected_attributes`.
      privileged_protected_attributes (list(numpy.ndarray)): A subset of
          protected attribute values which are considered privileged from a
          fairness perspective.
      unprivileged_protected_attributes (list(numpy.ndarray)): The remaining
          possible protected attribute values which are not included in
          `privileged_protected_attributes`.
      instance_names (list(str)): Indentifiers for each instance. Sequential
          integers by default.
      instance_weights (numpy.ndarray):  Weighting for each instance. All
          equal (ones) by default. Pursuant to standard practice in social
          science data, 1 means one person or entity. These weights are hence
          person or entity multipliers (see:
          https://www.ibm.com/support/knowledgecenter/en/SS3RA7_15.0.0/com.ibm.spss.modeler.help/netezza_decisiontrees_weights.htm)
          These weights *may not* be normalized to sum to 1 across the entire
          dataset, rather the nominal (default) weight of each entity/record
          in the data is 1. This is similar in spirit to the person weight in
          census microdata samples.
          https://www.census.gov/programs-surveys/acs/technical-documentation/pums/about.html
      ignore_fields (set(str)): Attribute names to ignore when doing equality
          comparisons. Always at least contains `'metadata'`.
      metadata (dict): Details about the creation of this dataset. For
          example::
  
              {
                  'transformer': 'Dataset.__init__',
                  'params': kwargs,
                  'previous': None
              }
class_docstr_tok: ["Base","class","for","all","structured","datasets",".","A","StructuredDataset","requires","data","to","be","stored","in",":","obj",":","`","numpy.ndarray","`","objects","with",":","obj",":","`","~numpy.dtype","`","as",":","obj",":","`","~numpy.float64","`",".","Attributes",":","features","(","numpy.ndarray",")",":","Dataset","features","for","each","instance",".","labels","(","numpy.ndarray",")",":","Generic","label","corresponding","to","each","instance","(","could","be","ground-truth",",","predicted",",","cluster","assignments",",","etc.",")",".","scores","(","numpy.ndarray",")",":","Probability","score","associated","with","each","label",".","Same","shape","as","`","labels","`",".","Only","valid","for","binary","labels","(","this","includes","one-hot","categorical","labels","as","well",")",".","protected_attributes","(","numpy.ndarray",")",":","A","subset","of","`","features","`","for","which","fairness","is","desired",".","feature_names","(","list","(","str",")",")",":","Names","describing","each","dataset","feature",".","label_names","(","list","(","str",")",")",":","Names","describing","each","label",".","protected_attribute_names","(","list","(","str",")",")",":","A","subset","of","`","feature_names","`","corresponding","to","`","protected_attributes","`",".","privileged_protected_attributes","(","list","(","numpy.ndarray",")",")",":","A","subset","of","protected","attribute","values","which","are","considered","privileged","from","a","fairness","perspective",".","unprivileged_protected_attributes","(","list","(","numpy.ndarray",")",")",":","The","remaining","possible","protected","attribute","values","which","are","not","included","in","`","privileged_protected_attributes","`",".","instance_names","(","list","(","str",")",")",":","Indentifiers","for","each","instance",".","Sequential","integers","by","default",".","instance_weights","(","numpy.ndarray",")",":","Weighting","for","each","instance",".","All","equal","(","ones",")","by","default",".","Pursuant","to","standard","practice","in","social","science","data",",","1","means","one","person","or","entity",".","These","weights","are","hence","person","or","entity","multipliers","(","see",":","https",":","\/\/www.ibm.com\/support\/knowledgecenter\/en\/SS3RA7_15.0.0\/com.ibm.spss.modeler.help\/netezza_decisiontrees_weights.htm",")","These","weights","*","may","not","*","be","normalized","to","sum","to","1","across","the","entire","dataset",",","rather","the","nominal","(","default",")","weight","of","each","entity\/record","in","the","data","is","1",".","This","is","similar","in","spirit","to","the","person","weight","in","census","microdata","samples",".","https",":","\/\/www.census.gov\/programs-surveys\/acs\/technical-documentation\/pums\/about.html","ignore_fields","(","set","(","str",")",")",":","Attribute","names","to","ignore","when","doing","equality","comparisons",".","Always","at","least","contains","`","'metadata","'","`",".","metadata","(","dict",")",":","Details","about","the","creation","of","this","dataset",".","For","example",":",":","{","'transformer","'",":","'Dataset.__init__","'",",","'params","'",":","kwargs",",","'previous","'",":","None","}"]
docstr: Convert the StructuredDataset to a :obj:`pandas.DataFrame`.
  
  Args:
      de_dummy_code (bool): Performs de_dummy_coding, converting dummy-
          coded columns to categories. If `de_dummy_code` is `True` and
          this dataset contains mappings for label and/or protected
          attribute values to strings in the `metadata`, this method will
          convert those as well.
      sep (char): Separator between the prefix in the dummy indicators and
          the dummy-coded categorical levels.
      set_category (bool): Set the de-dummy coded features to categorical
          type.
  
  Returns:
      (pandas.DataFrame, dict):
  
          * `pandas.DataFrame`: Equivalent dataframe for a dataset. All
            columns will have only numeric values. The
            `protected_attributes` field in the dataset will override the
            values in the `features` field.
  
          * `dict`: Attributes. Will contain additional information pulled
            from the dataset such as `feature_names`, `label_names`,
            `protected_attribute_names`, `instance_names`,
            `instance_weights`, `privileged_protected_attributes`,
            `unprivileged_protected_attributes`. The metadata will not be
            returned.
docstr_tok: ["Convert","the","StructuredDataset","to","a",":","obj",":","`","pandas.DataFrame","`",".","Args",":","de_dummy_code","(","bool",")",":","Performs","de_dummy_coding",",","converting","dummy-","coded","columns","to","categories",".","If","`","de_dummy_code","`","is","`","True","`","and","this","dataset","contains","mappings","for","label","and\/or","protected","attribute","values","to","strings","in","the","`","metadata","`",",","this","method","will","convert","those","as","well",".","sep","(","char",")",":","Separator","between","the","prefix","in","the","dummy","indicators","and","the","dummy-coded","categorical","levels",".","set_category","(","bool",")",":","Set","the","de-dummy","coded","features","to","categorical","type",".","Returns",":","(","pandas.DataFrame",",","dict",")",":","*","`","pandas.DataFrame","`",":","Equivalent","dataframe","for","a","dataset",".","All","columns","will","have","only","numeric","values",".","The","`","protected_attributes","`","field","in","the","dataset","will","override","the","values","in","the","`","features","`","field",".","*","`","dict","`",":","Attributes",".","Will","contain","additional","information","pulled","from","the","dataset","such","as","`","feature_names","`",",","`","label_names","`",",","`","protected_attribute_names","`",",","`","instance_names","`",",","`","instance_weights","`",",","`","privileged_protected_attributes","`",",","`","unprivileged_protected_attributes","`",".","The","metadata","will","not","be","returned","."]
code: def convert_to_dataframe(
      self, de_dummy_code=False, sep="=", set_category=True
  ):
      """Convert the StructuredDataset to a :obj:`pandas.DataFrame`.
  
      Args:
          de_dummy_code (bool): Performs de_dummy_coding, converting dummy-
              coded columns to categories. If `de_dummy_code` is `True` and
              this dataset contains mappings for label and/or protected
              attribute values to strings in the `metadata`, this method will
              convert those as well.
          sep (char): Separator between the prefix in the dummy indicators and
              the dummy-coded categorical levels.
          set_category (bool): Set the de-dummy coded features to categorical
              type.
  
      Returns:
          (pandas.DataFrame, dict):
  
              * `pandas.DataFrame`: Equivalent dataframe for a dataset. All
                columns will have only numeric values. The
                `protected_attributes` field in the dataset will override the
                values in the `features` field.
  
              * `dict`: Attributes. Will contain additional information pulled
                from the dataset such as `feature_names`, `label_names`,
                `protected_attribute_names`, `instance_names`,
                `instance_weights`, `privileged_protected_attributes`,
                `unprivileged_protected_attributes`. The metadata will not be
                returned.
  
      """
      df = pd.DataFrame(
          np.hstack((self.features, self.labels)),
          columns=self.feature_names + self.label_names,
          index=self.instance_names,
      )
      df.loc[
          :, self.protected_attribute_names
      ] = self.protected_attributes
  
      # De-dummy code if necessary
      if de_dummy_code:
          df = self._de_dummy_code_df(
              df, sep=sep, set_category=set_category
          )
          if "label_maps" in self.metadata:
              for i, label in enumerate(self.label_names):
                  df[label] = df[label].replace(
                      self.metadata["label_maps"][i]
                  )
          if "protected_attribute_maps" in self.metadata:
              for i, prot_attr in enumerate(
                  self.protected_attribute_names
              ):
                  df[prot_attr] = df[prot_attr].replace(
                      self.metadata["protected_attribute_maps"][i]
                  )
  
      # Attributes
      attributes = {
          "feature_names": self.feature_names,
          "label_names": self.label_names,
          "protected_attribute_names": self.protected_attribute_names,
          "instance_names": self.instance_names,
          "instance_weights": self.instance_weights,
          "privileged_protected_attributes": self.privileged_protected_attributes,
          "unprivileged_protected_attributes": self.unprivileged_protected_attributes,
      }
  
      return df, attributes
  
imports: from collections import defaultdict
  from contextlib import contextmanager
  from copy import deepcopy
  from logging import warning
  import numpy
  import pandas
  from aif360.datasets import Dataset
label_desc: Use image node_id 10 for calling the StructuredDataset obj's underlying member method code with example usage: obj.convert_to_dataframe(de_dummy_code, sep, set_category) and returns: df,  attributes