Explore Library
Code QuizIntermediate

Aggregating Bagging Votes

Spot the bug in majority voting over ensemble tree predictions.

Codepython
from collections import Counter

def bagging_predict(tree_preds):
    # tree_preds: class label from each tree
    counts = Counter(tree_preds)
    return counts.most_common()[-1][0]

This should return the majority-voted class label. What is the bug?