Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-138

Bagging Vote Prediction

Problem

Majority vote of bagged models on each sample. predictions is a list of models, each with one predicted label per sample; for each sample take the most common label across models.

Ties are broken by the smallest label. Empty input returns [].

Hint

Count labels per sample and pick the leader, breaking ties by the smallest label.

Test cases

case 1
in: [[["a","b","a"],["a","b","b"]]]
expected: ["a","b","a"]
case 2
in: [[[1,0],[1,1],[0,1]]]
expected: [1,1]
case 3
in: [[[3,1,2]]]
expected: [3,1,2]
case 4
in: [[]]
expected: []
Starter codePython
def bagging_vote(predictions):
    # Your code here
    pass

4 test cases · run your code against them in the editor