Compute the Gini impurity of a node from its class counts.
Implement solve(counts).
Returns. Return a float in [0,1). Counts must be non-negative (otherwise ValueError). A node with no samples at all has impurity 0.0.
Example 1
Input:
solve([2, 2])
Output:
0.5
Example 2
Input:
solve([5, 0, 0])
Output:
0.0
Example 3
Input:
solve([1, 1, 1, 1])
Output:
0.75
No results yet
Run your code to check it against the examples, or submit to run every test.