Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-228

Information Value

Problem

Compute the information value of a binned feature: sum over bins of (good_share - bad_share) * ln(good_share / bad_share), clipping shares to at least 1e-6.

Return 0.0 if a total is 0.

Hint

IV sums each bin's share difference weighted by its WOE.

Test cases

case 1
in: [[30,20,50],[10,40,50]]
expected: 0.35835189384561095
case 2
in: [[50,50],[50,50]]
expected: 0
case 3
in: [[80,20],[20,80]]
expected: 1.663553233343869
case 4
in: [[],[]]
expected: 0
Starter codePython
import math
def information_value(good_counts, bad_counts):
    # Your code here
    pass

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