All problems
WOE Information Contribution
Problem
Compute each bin's contribution to information value: (good_share - bad_share) * ln(good_share / bad_share), clipping every share to at least 1e-6. Return one contribution per bin; if either total is 0 return a list of zeros and an empty input returns [].
Hint
Summing these per-bin contributions recovers the information value of the feature.
Test cases
case 1
in: [[30,20,50],[10,40,50]]
expected: [0.2197224577336219,0.13862943611198905,0]
case 2
in: [[50,50],[50,50]]
expected: [0,0]
case 3
in: [[],[]]
expected: []
case 4
in: [[0,10,0],[5,0,5]]
expected: [6.561168566338787,13.815496742453716,6.561168566338787]
Starter codePython
import math
def woe_contributions(good_counts, bad_counts):
# Your code here
pass4 test cases · run your code against them in the editor