Example #1
0
 def classify(self, example):
     predictions = [tree.classify(example) for tree in self.trees]
     counts = defaultdict(int)
     for p in predictions:
         counts[p] += 1
     cls, count = dt_util.get_plurality(counts)
     return cls
Example #2
0
 def evaluate_chi_square(self, chi_square, unsplit_counts):
   if chi_square <= CONFIDENCE_BOUND:
     return self
   
   print "++ Pruned"
   best_class, best_val = dt_util.get_plurality(unsplit_counts)
   return decision_tree_leaf(best_class, unsplit_counts)
Example #3
0
 def classify(self, example):
   predictions = [tree.classify(example) for tree in self.trees]
   counts = defaultdict(int)
   for p in predictions:
     counts[p] += 1
   cls, count = dt_util.get_plurality(counts)
   return cls