Exemplo n.º 1
0
 def get_best_evaluated_split_suggestion(self,
                                         criterion,
                                         pre_split_dist,
                                         att_idx,
                                         class_idx=None):
     best_suggestion = None
     suggested_split_values = self.get_split_point_suggestions()
     for expand_value in suggested_split_values:
         post_split_dist = self.get_class_dists_from_binary_split(
             expand_value)
         if class_idx is not None:
             criterion.class_idx = class_idx
         merit = criterion.get_merit_of_split(pre_split_dist,
                                              post_split_dist)
         if best_suggestion is None or merit > best_suggestion.merit:
             if criterion.best_idx == 0:
                 symbol = "<="
             else:
                 symbol = ">"
             best_suggestion = AttributeExpandSuggestion(
                 att_idx, expand_value, symbol, post_split_dist, merit)
     return best_suggestion
 def get_best_evaluated_split_suggestion(self,
                                         criterion,
                                         pre_split_dist,
                                         att_idx,
                                         class_idx=None):
     best_suggestion = None
     att_values = set([
         att_val for class_val in self._att_val_dist_per_class.values()
         for att_val in class_val
     ])
     for att_val in att_values:
         post_split_dist = self.get_class_dist_from_binary_split(att_val)
         if class_idx is not None:
             criterion.class_idx = class_idx
         merit = criterion.get_merit_of_split(pre_split_dist,
                                              post_split_dist)
         if best_suggestion is None or merit > best_suggestion.merit:
             if criterion.best_idx == 0:
                 symbol = "="
             else:
                 symbol = "!="
             best_suggestion = AttributeExpandSuggestion(
                 att_idx, att_val, symbol, post_split_dist, merit)
     return best_suggestion