2016-05-26 20 views
0

Ich habe die Bibliothek Smbinning verwendet, um IV zu finden .. Ich habe meine Daten gereinigt und es gab keine NAs in meinem Datensatz. Ich habe ein Beispiel für eine kontinuierliche Variable und eine mit einer Faktorvariablen gezeigt und die IV berechnet.Warum bekomme ich Nan während der Berechnung IV/Scorecard/WOE in R

library(smbinning) 

**# time is continuous variable and shot_made_flag is dependent variable** 
time=smbinning(df=train,y="shot_made_flag",x="time",p=0.05) 
Warning message: 
NAs introduced by coercion 

time$ivtable 

    Cutpoint CntRec CntGood CntBad CntCumRec CntCumGood CntCumBad PctRec GoodRate BadRate Odds LnOdds  WoE 
1 <= 22 1031  328 703  1031  328  703 0.0573 0.3181 0.6819 0.4666 -0.7623 -0.5461 
2 <= 714 16956 7697 9259  17987  8025  9962 0.9427 0.4539 0.5461 0.8313 -0.1848 0.0315 
3 Missing  0  0  0  17987  8025  9962 0.0000  NaN  NaN NaN  NaN  NaN 
4 Total 17987 8025 9962  NA   NA  NA 1.0000 0.4462 0.5538 0.8056 -0.2162 0.0000 
     IV 
1 0.0162 
2 0.0009 
3 NaN 
4 0.0171 


**# combined_shot_type is factor variable and shot_made_flag is dependent variable** 

combined_shot_type=smbinning.factor(df=train,y="shot_made_flag",x="combined_shot_type") 
Warning message: 
NAs introduced by coercion 

combined_shot_type$ivtable 

    Cutpoint CntRec CntGood CntBad CntCumRec CntCumGood CntCumBad PctRec GoodRate BadRate Odds LnOdds 
1 = Bank Shot  83  63  20  83   63  20 0.0046 0.7590 0.2410 3.1500 1.1474 
2  = Dunk 723  671  52  806  734  72 0.0402 0.9281 0.0719 12.9038 2.5575 
3 = Hook Shot  88  48  40  894  782  112 0.0049 0.5455 0.4545 1.2000 0.1823 
4 = Jump Shot 13814 5390 8424  14708  6172  8536 0.7680 0.3902 0.6098 0.6398 -0.4465 
5  = Layup 3170 1811 1359  17878  7983  9895 0.1762 0.5713 0.4287 1.3326 0.2871 
6 = Tip Shot 109  42  67  17987  8025  9962 0.0061 0.3853 0.6147 0.6269 -0.4670 
7  Missing  0  0  0  17987  8025  9962 0.0000  NaN  NaN  NaN  NaN 
8  Total 17987 8025 9962  NA   NA  NA 1.0000 0.4462 0.5538 0.8056 -0.2162 
     WoE  IV 
1 1.3636 0.0080 
2 2.7737 0.2174 
3 0.3985 0.0008 
4 -0.2303 0.0401 
5 0.5033 0.0449 
6 -0.2508 0.0004 
7  NaN NaN 
8 0.0000 0.3116 

Antwort

0

Sie erhalten NaN, nur für die Zeilen, die den fehlenden Werten entsprechen. Das ist vollkommen normal und Sie können diese Zeilen einfach ignorieren.

Da Sie die NAs in Ihrem Dataset entfernt haben, fehlen keine Daten. Daher hat Ihre "Fehlende" Gruppe 0 Beobachtungen und die WOE dieser Gruppe kann nicht berechnet werden. Deine letzte IV ist die Summe aller anderen IVs. Alles ist gut. :)