use of org.dmg.pmml.ContStats in project shifu by ShifuML.
the class ModelStatsCreator method createConStats.
/**
* Create @ConStats for numerical variable
*
* @param columnConfig
* - ColumnConfig to generate ConStats
* @return ConStats for variable
*/
private ContStats createConStats(ColumnConfig columnConfig) {
ContStats conStats = new ContStats();
List<Interval> intervals = new ArrayList<Interval>();
for (int i = 0; i < columnConfig.getBinBoundary().size(); i++) {
Interval interval = new Interval();
interval.setClosure(Interval.Closure.OPEN_CLOSED);
interval.setLeftMargin(columnConfig.getBinBoundary().get(i));
if (i == columnConfig.getBinBoundary().size() - 1) {
interval.setRightMargin(Double.POSITIVE_INFINITY);
} else {
interval.setRightMargin(columnConfig.getBinBoundary().get(i + 1));
}
intervals.add(interval);
}
conStats.addIntervals(intervals.toArray(new Interval[intervals.size()]));
Map<String, String> extensionMap = new HashMap<String, String>();
extensionMap.put("BinCountPos", columnConfig.getBinCountPos().toString());
extensionMap.put("BinCountNeg", columnConfig.getBinCountNeg().toString());
extensionMap.put("BinWeightedCountPos", columnConfig.getBinWeightedPos().toString());
extensionMap.put("BinWeightedCountNeg", columnConfig.getBinWeightedNeg().toString());
extensionMap.put("BinPosRate", columnConfig.getBinPosRate().toString());
extensionMap.put("BinWOE", calculateWoe(columnConfig.getBinCountPos(), columnConfig.getBinCountNeg()).toString());
extensionMap.put("KS", Double.toString(columnConfig.getKs()));
extensionMap.put("IV", Double.toString(columnConfig.getIv()));
List<Extension> extensions = createExtensions(extensionMap);
conStats.addExtensions(extensions.toArray(new Extension[extensions.size()]));
return conStats;
}