Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-139

Random Forest Probability Vote

Problem

Random forest probability vote. tree_probs[t][j] is tree t's class probability vector for sample j; average the probabilities across trees and pick the class with the largest mean probability.

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

Hint

Average the per-tree probabilities first, then take the argmax per sample.

Test cases

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

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