@Test public void testWoe(){ long positive = 2500; long negative = 47500; long total = 100000; long positiveTotal = 10000; Assert.assertEquals(FeatureBinsUtil.calcWoe(positive + negative, positive, positiveTotal, total - positiveTotal), -0.74, 0.01); }
public static double calcWoe(long binTotal, long binPositiveTotal, long positiveTotal, long negativeTotal){ long binNegativeTotal = binTotal - binPositiveTotal; Double woe = Double.NaN; if(positiveTotal > 0 && negativeTotal > 0){ double binPositiveRate = 1.0 * (binPositiveTotal + 0.5) / positiveTotal; double binNegativeRate = 1.0 * (binNegativeTotal + 0.5) / negativeTotal; woe = Math.log(binPositiveRate / binNegativeRate); } return woe; }
FeatureBinsUtil { public static double calcWoe(long binTotal, long binPositiveTotal, long positiveTotal, long negativeTotal){ long binNegativeTotal = binTotal - binPositiveTotal; Double woe = Double.NaN; if(positiveTotal > 0 && negativeTotal > 0){ double binPositiveRate = 1.0 * (binPositiveTotal + 0.5) / positiveTotal; double binNegativeRate = 1.0 * (binNegativeTotal + 0.5) / negativeTotal; woe = Math.log(binPositiveRate / binNegativeRate); } return woe; } }
FeatureBinsUtil { public static double calcWoe(long binTotal, long binPositiveTotal, long positiveTotal, long negativeTotal){ long binNegativeTotal = binTotal - binPositiveTotal; Double woe = Double.NaN; if(positiveTotal > 0 && negativeTotal > 0){ double binPositiveRate = 1.0 * (binPositiveTotal + 0.5) / positiveTotal; double binNegativeRate = 1.0 * (binNegativeTotal + 0.5) / negativeTotal; woe = Math.log(binPositiveRate / binNegativeRate); } return woe; }  }
FeatureBinsUtil { public static double calcWoe(long binTotal, long binPositiveTotal, long positiveTotal, long negativeTotal){ long binNegativeTotal = binTotal - binPositiveTotal; Double woe = Double.NaN; if(positiveTotal > 0 && negativeTotal > 0){ double binPositiveRate = 1.0 * (binPositiveTotal + 0.5) / positiveTotal; double binNegativeRate = 1.0 * (binNegativeTotal + 0.5) / negativeTotal; woe = Math.log(binPositiveRate / binNegativeRate); } return woe; }  static BinTypes.ColType featureTypeToColType(String featureType, BinDivideType binDivideType); static String getTypeString(TypeInformation<?> type); static TypeInformation<?> getFlinkType(String typeStr); static Double keepGivenDecimal(Double d, int decimal); static Number keepGivenDecimal(Number d, int decimal); static DataSet<FeatureBinsCalculator> parseFeatureBinsModel(DataSet<Row> modelData); static int compareNumbers(Number o1, Number o2); static FeatureBinsCalculator[] deSerialize(String str); static String serialize(FeatureBinsCalculator... featureBinsCalculators); static double calcWoe(long binTotal, long binPositiveTotal, long positiveTotal, long negativeTotal); static long nullIndex(int normBinSize); static long elseIndex(int normBinSize); static int getBinEncodeVectorSize(FeatureBinsCalculator featureBinsCalculator); static String[] cutsArrayToInterval(Number[] splitsArray, boolean leftOpen); }
FeatureBinsUtil { public static double calcWoe(long binTotal, long binPositiveTotal, long positiveTotal, long negativeTotal){ long binNegativeTotal = binTotal - binPositiveTotal; Double woe = Double.NaN; if(positiveTotal > 0 && negativeTotal > 0){ double binPositiveRate = 1.0 * (binPositiveTotal + 0.5) / positiveTotal; double binNegativeRate = 1.0 * (binNegativeTotal + 0.5) / negativeTotal; woe = Math.log(binPositiveRate / binNegativeRate); } return woe; }  static BinTypes.ColType featureTypeToColType(String featureType, BinDivideType binDivideType); static String getTypeString(TypeInformation<?> type); static TypeInformation<?> getFlinkType(String typeStr); static Double keepGivenDecimal(Double d, int decimal); static Number keepGivenDecimal(Number d, int decimal); static DataSet<FeatureBinsCalculator> parseFeatureBinsModel(DataSet<Row> modelData); static int compareNumbers(Number o1, Number o2); static FeatureBinsCalculator[] deSerialize(String str); static String serialize(FeatureBinsCalculator... featureBinsCalculators); static double calcWoe(long binTotal, long binPositiveTotal, long positiveTotal, long negativeTotal); static long nullIndex(int normBinSize); static long elseIndex(int normBinSize); static int getBinEncodeVectorSize(FeatureBinsCalculator featureBinsCalculator); static String[] cutsArrayToInterval(Number[] splitsArray, boolean leftOpen); static String NULL_LABEL; static String ELSE_LABEL; }