All problems
Misclassification Error of a Node
Problem
Compute the misclassification error of a label list, defined as 1 - max(p_i) where p_i is the empirical frequency of each distinct label. Return 0.0 for an empty list.
Hint
The error is the fraction of samples not belonging to the majority class.
Test cases
case 1
in: [["a","a","b"]]
expected: 0.33333333333333337
case 2
in: [["a","b"]]
expected: 0.5
case 3
in: [["a","a"]]
expected: 0
case 4
in: [[]]
expected: 0
case 5
in: [["a","a","a","b"]]
expected: 0.25
Starter codePython
def misclassification_error(labels):
# Your code here
pass5 test cases · run your code against them in the editor