Turn the impurity reductions of the splits in a tree into feature importances. splits is a list of (feature, impurity_reduction) pairs, one per internal node. Sum the reductions per feature and normalise so the importances add up to 1.
Implement solve(splits).
Returns. Return a dict {feature: importance} in order of first appearance. If the total reduction is 0 the un-normalised sums are returned.
Example 1
Input:
solve([('a', 1.0), ('b', 2.0), ('a', 1.0)])
Output:
{'a': 0.5, 'b': 0.5}
Example 2
Input:
solve([('x', 0.3), ('y', 0.1)])
Output:
{'x': 0.75, 'y': 0.25}
No results yet
Run your code to check it against the examples, or submit to run every test.