X = pd.DataFrame({"num_legs": [4], "num_eyes": [2]}) mode.score(X)
dog
def predict(x): num_legs = x["num_legs"] num_eyes = x["num_eyes"] if num_legs >= 3: if num_eyes >= 3: return "spider" else: return "dog" else: return "penguin"
Add a penalty for tree complexity to the cost function:
where is the misclassification rate of tree , is a complexity parameter, and is the number of leaves in the tree.