Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-099

Ensemble Soft Voting

Problem

Average the class probabilities of an ensemble element-wise, then return the argmax class per row, breaking ties by the smaller class index.

The signature is ensemble_soft_voting(probs_list). probs_list is a list of models, each contributing a (rows, classes) probability matrix.

Hint

Average the probabilities first, then take the argmax; strict greater-than keeps ties at the smaller index.

Test cases

case 1
in: [[[[0.1,0.6,0.3]],[[0.2,0.5,0.3]]]]
expected: [1]
case 2
in: [[[[0.2,0.5,0.3],[0.6,0.3,0.1]],[[0.2,0.5,0.3],[0.4,0.3,0.3]]]]
expected: [1,0]
case 3
in: [[[[0.5,0.5]]]]
expected: [0]
case 4
in: [[[[0.4,0.4],[0.3,0.7]],[[0.4,0.4],[0.7,0.3]]]]
expected: [0,0]
Starter codePython
def ensemble_soft_voting(probs_list):
    # Your code here
    pass

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