All problems
Weighted Ensemble Vote
Problem
Weighted majority vote across models per sample. predictions[m][j] is model m's label for sample j and weights[m] is the model weight; for each sample sum the weights per label and pick the largest total.
Ties go to the smallest label. Empty predictions returns [].
Hint
Weighted voting lets stronger models dominate the ensemble decision.
Test cases
case 1
in: [[["a","b"],["b","b"],["a","a"]],[1,2,1]]
expected: ["a","b"]
case 2
in: [[[1,0,1],[0,0,1]],[3,1]]
expected: [1,0,1]
case 3
in: [[[2,1]],[0.5]]
expected: [2,1]
case 4
in: [[],[]]
expected: []
Starter codePython
def weighted_ensemble_vote(predictions, weights):
# Your code here
pass4 test cases · run your code against them in the editor