Ejemplo n.º 1
0
 def plurality_value(examples):
     """
     Return the most popular target value for this set of examples.
     (If target is binary, this is the majority; otherwise plurality).
     """
     popular = argmax_random_tie(values[target], key=lambda v: count(target, v, examples))
     return DecisionLeaf(popular)
Ejemplo n.º 2
0
 def choose_attribute(attrs, examples):
     """Choose the attribute with the highest information gain."""
     return argmax_random_tie(attrs,
                              key=lambda a: information_gain(a, examples))