use of ml.shifu.shifu.container.ValueObject in project shifu by ShifuML.
the class Binning method doBinning.
/**
* Numerical: Raw to Value Conversion happens before Binning
* <p>
* Categorical: Raw to Value Conversion happens after Binning
* <p>
* Start binning method
*/
public void doBinning() {
// otherwise as Numerical;
if (dataType.equals(BinningDataType.Auto)) {
int cntRaw = 0;
int cntValue = 0;
for (ValueObject vo : voList) {
if (vo.getValue() != null) {
cntValue++;
} else {
cntRaw++;
}
}
Set<Object> keySet = new HashSet<Object>();
for (ValueObject vo : voList) {
if (vo.getValue() != null) {
keySet.add(vo.getValue());
} else {
keySet.add(vo.getRaw());
}
if (keySet.size() > this.autoTypeThreshold) {
break;
}
}
if (cntRaw > 0 || keySet.size() <= this.autoTypeThreshold) {
this.dataType = BinningDataType.Categorical;
if (cntValue > 0) {
for (ValueObject vo : voList) {
if (vo.getRaw() == null) {
vo.setRaw(vo.getValue().toString());
}
}
}
// log.info("FinalType: Categorical");
} else {
this.dataType = BinningDataType.Numerical;
// log.info("FinalType: Numerical");
}
}
if (dataType.equals(BinningDataType.Categorical)) {
doCategoricalBinning();
} else if (dataType.equals(BinningDataType.Numerical)) {
doNumericalBinning();
}
}
Aggregations