Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-227

Weight of Evidence

Problem

Compute the weight of evidence for one bin: ln((good_c/good_total) / (bad_c/bad_total)), clipping each distribution share to at least 1e-6.

Return 0.0 if a total is 0.

Hint

WOE compares the good and bad distributions inside a bin.

Test cases

case 1
in: [30,10,100,100]
expected: 1.0986122886681096
case 2
in: [20,40,100,100]
expected: -0.6931471805599453
case 3
in: [50,50,100,100]
expected: 0
case 4
in: [0,10,100,100]
expected: -11.512925464970229
Starter codePython
import math
def woe(good_c, bad_c, good_total, bad_total):
    # Your code here
    pass

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