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: Split this dataset into multiple partitions.
  
  Args:
      num_or_size_splits (array or int): If `num_or_size_splits` is an
          int, *k*, the value is the number of equal-sized folds to make
          (if *k* does not evenly divide the dataset these folds are
          approximately equal-sized). If `num_or_size_splits` is an array
          of type int, the values are taken as the indices at which to
          split the dataset. If the values are floats (< 1.), they are
          considered to be fractional proportions of the dataset at which
          to split.
      shuffle (bool, optional): Randomly shuffle the dataset before
          splitting.
      seed (int or array_like): Takes the same argument as
          :func:`numpy.random.seed()`.
  
  Returns:
      list: Splits. Contains *k* or `len(num_or_size_splits) + 1`
      datasets depending on `num_or_size_splits`.
docstr_tok: ["Split","this","dataset","into","multiple","partitions",".","Args",":","num_or_size_splits","(","array","or","int",")",":","If","`","num_or_size_splits","`","is","an","int",",","*","k","*",",","the","value","is","the","number","of","equal-sized","folds","to","make","(","if","*","k","*","does","not","evenly","divide","the","dataset","these","folds","are","approximately","equal-sized",")",".","If","`","num_or_size_splits","`","is","an","array","of","type","int",",","the","values","are","taken","as","the","indices","at","which","to","split","the","dataset",".","If","the","values","are","floats","(","<","1",".",")",",","they","are","considered","to","be","fractional","proportions","of","the","dataset","at","which","to","split",".","shuffle","(","bool",",","optional",")",":","Randomly","shuffle","the","dataset","before","splitting",".","seed","(","int","or","array_like",")",":","Takes","the","same","argument","as",":","func",":","`","numpy.random.seed","(",")","`",".","Returns",":","list",":","Splits",".","Contains","*","k","*","or","`","len","(","num_or_size_splits",")","+","1","`","datasets","depending","on","`","num_or_size_splits","`","."]
code: def split(self, num_or_size_splits, shuffle=False, seed=None):
      """Split this dataset into multiple partitions.
  
      Args:
          num_or_size_splits (array or int): If `num_or_size_splits` is an
              int, *k*, the value is the number of equal-sized folds to make
              (if *k* does not evenly divide the dataset these folds are
              approximately equal-sized). If `num_or_size_splits` is an array
              of type int, the values are taken as the indices at which to
              split the dataset. If the values are floats (< 1.), they are
              considered to be fractional proportions of the dataset at which
              to split.
          shuffle (bool, optional): Randomly shuffle the dataset before
              splitting.
          seed (int or array_like): Takes the same argument as
              :func:`numpy.random.seed()`.
  
      Returns:
          list: Splits. Contains *k* or `len(num_or_size_splits) + 1`
          datasets depending on `num_or_size_splits`.
      """
  
      # Set seed
      if seed is not None:
          np.random.seed(seed)
  
      n = self.features.shape[0]
      if isinstance(num_or_size_splits, list):
          num_folds = len(num_or_size_splits) + 1
          if num_folds > 1 and all(
              x <= 1.0 for x in num_or_size_splits
          ):
              num_or_size_splits = [
                  int(x * n) for x in num_or_size_splits
              ]
      else:
          num_folds = num_or_size_splits
  
      order = list(np.random.permutation(n) if shuffle else range(n))
      folds = [self.copy() for _ in range(num_folds)]
  
      features = np.array_split(
          self.features[order], num_or_size_splits
      )
      labels = np.array_split(self.labels[order], num_or_size_splits)
      scores = np.array_split(self.scores[order], num_or_size_splits)
      protected_attributes = np.array_split(
          self.protected_attributes[order], num_or_size_splits
      )
      instance_weights = np.array_split(
          self.instance_weights[order], num_or_size_splits
      )
      instance_names = np.array_split(
          np.array(self.instance_names)[order], num_or_size_splits
      )
      for (
          fold,
          feats,
          labs,
          scors,
          prot_attrs,
          inst_wgts,
          inst_name,
      ) in zip(
          folds,
          features,
          labels,
          scores,
          protected_attributes,
          instance_weights,
          instance_names,
      ):
          fold.features = feats
          fold.labels = labs
          fold.scores = scors
          fold.protected_attributes = prot_attrs
          fold.instance_weights = inst_wgts
          fold.instance_names = list(map(str, inst_name))
          fold.metadata = fold.metadata.copy()
          fold.metadata.update(
              {
                  "transformer": "{}.split".format(type(self).__name__),
                  "params": {
                      "num_or_size_splits": num_or_size_splits,
                      "shuffle": shuffle,
                  },
                  "previous": [self],
              }
          )
  
      return folds
  
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 13 for calling the StructuredDataset obj's underlying member method code with example usage: obj.split(num_or_size_splits, shuffle, seed) and returns: folds