class_docstr: A Partition is a set of non-overlapping bins of the same type associated with the same feature
class_docstr_tok: ["A","Partition","is","a","set","of","non-overlapping","bins","of","the","same","type","associated","with","the","same","feature"]
docstr: @param bins: A list of instances of a subclass of GeneralizedBin. All elements must have the same type.
docstr_tok: ["@","param","bins",":","A","list","of","instances","of","a","subclass","of","GeneralizedBin",".","All","elements","must","have","the","same","type","."]
code: def __init__(self, bins: List[Bin]):
      """
      @param bins: A list of instances of a subclass of GeneralizedBin. All elements must have the same type.
      """
      if len(bins) == 0:
          raise ValueError(
              'Need len(bins) > 0 but len(bins) = "{}"'.format(
                  len(bins)
              )
          )
  
      # Check that all bins are associated with the same feature and have the same type
      self._feature = bins[0].feature
      bin_type = type(bins[0])
      for idx, curr_bin in enumerate(bins):
          if curr_bin.feature != self._feature:
              raise ValueError(
                  "All bins must be associated with the same feature but bins[0] was associated with"
                  '"{}" whereas bins["{}"] was associated with "{}"'.format(
                      self._feature, idx, curr_bin.feature
                  )
              )
          if type(curr_bin) != bin_type:
              raise ValueError(
                  'All bins must have the same type but bins[0] has type "{}" while bins["{}"]'
                  'has type "{}"'.format(bin_type, idx, type(curr_bin))
              )
  
      # Check that bins do not overlap
      for idx1 in range(len(bins)):
          for idx2 in range(idx1 + 1, len(bins)):
              if bins[idx1].overlaps(bins[idx2]):
                  raise ValueError(
                      'Bins must be non-overlapping but bin "{}" overlaps with bin "{}"'.format(
                          bins[idx1], bins[idx2]
                      )
                  )
  
      self._bins = bins
  
file_path: AIX360/aix360/algorithms/rule_induction/trxf/scorecard/partition.py
imports: from typing import List, Dict, Any
  from aix360.algorithms.rule_induction.trxf.core import Feature
  from aix360.algorithms.rule_induction.trxf.scorecard import Bin
label_desc: Use image node_id 1 to create a new Partition object from inherited base classes: object with example: obj = Partition(bins)