Search in sources :

Example 6 with ValueObject

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();
    }
}
Also used : ValueObject(ml.shifu.shifu.container.ValueObject) ValueObject(ml.shifu.shifu.container.ValueObject)

Aggregations

ValueObject (ml.shifu.shifu.container.ValueObject)6 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ColumnConfig (ml.shifu.shifu.container.obj.ColumnConfig)1 ShifuException (ml.shifu.shifu.exception.ShifuException)1