The HPBIN Procedure

Example 4.5 Bucket Binning and Weight-of-Evidence Computation

This example shows bucket binning and weight-of-evidence (WOE) computation in two steps. In the first step, PROC HPBIN does bucket binning and generates the mapping table. In the second step, PROC HPBIN takes the mapping table that is generated in the first step as the BINS_META data set and computes the WOE and the information value (IV).


data ex12;
input cl1 $ x0  x1  x2  y $ freq id;
cards;
       a     2    .   7  n   2   1
       a     2    2   6  .   3   2
       a     3    0   1  o   0   3
       c     2    3   7  y   .   4
       c     2    .   4  n   -5  5
       a     3    6   7  n   3   6
       b     1    4   4  y   4   7
       b     2    5   6  y   3   8
       b     1    6   4  o   1   9
       b     2    3   2  n   3   10
run;


 proc hpbin data=ex12 numbin=5;
     input x1/numbin=4;
     input x2;
     ods output Mapping=Mapping;
 run;

 proc hpbin data=ex12 WOE BINS_META=Mapping;
     target y/level=nominal order=desc;
 run;

Output 4.5.1: Number of Observations Table

The HPBIN Procedure

Number of Observations Read 10
Number of Observations Used 7



Output 4.5.2: Weight-of-Evidence Table

Weight of Evidence
Variable Binned Variable Range Non-event
Count
Non-event
Rate
Event
Count
Event
Rate
Weight of
Evidence
Information
Value
x1 BIN_x1   2 1 0 0 0.91629073 0.30543024
    x1 < 1.500000 1 1 0 0 0.40546511 0.06757752
    1.500000 <= x1 < 3.000000 0 0 0 0 0 0
    3.000000 <= x1 < 4.500000 1 0.33333333 2 0.66666667 -1.3862944 0.69314718
    4.500000 <= x1 2 0.66666667 1 0.33333333 0 0
x2 BIN_x2   0 0 0 0 0 0
    x2 < 2.200000 2 1 0 0 0.91629073 0.30543024
    2.200000 <= x2 < 3.400000 0 0 0 0 0 0
    3.400000 <= x2 < 4.600000 2 0.66666667 1 0.33333333 0 0
    4.600000 <= x2 < 5.800000 0 0 0 0 0 0
    5.800000 <= x2 2 0.50000000 2 0.50000000 -0.6931472 0.23104906



Output 4.5.3: Variable Information Value Table

Variable Information
Value
Variable Information Value
x1 1.06615494
x2 0.53647930