Search in sources :

Example 1 with Closure

use of org.knime.core.util.binning.auto.pmml.Closure in project knime-core by knime.

the class AutoBinnerUtility method getNumericBin.

private static NumericBin getNumericBin(final PMMLDiscretizeBin bin) {
    final String binName = bin.getBinValue();
    final List<PMMLInterval> intervals = bin.getIntervals();
    boolean leftOpen = false;
    boolean rightOpen = false;
    double leftMargin = 0;
    double rightMargin = 0;
    // always returns only one interval
    for (PMMLInterval interval : intervals) {
        final Closure closure = interval.getClosure();
        switch(closure) {
            case OPEN_CLOSED:
                leftOpen = true;
                rightOpen = false;
                break;
            case OPEN_OPEN:
                leftOpen = true;
                rightOpen = true;
                break;
            case CLOSED_OPEN:
                leftOpen = false;
                rightOpen = true;
                break;
            case CLOSED_CLOSED:
                leftOpen = false;
                rightOpen = false;
                break;
            default:
                leftOpen = true;
                rightOpen = false;
                break;
        }
        leftMargin = interval.getLeftMargin();
        rightMargin = interval.getRightMargin();
    }
    return new NumericBin(binName, leftOpen, leftMargin, rightOpen, rightMargin);
}
Also used : NumericBin(org.knime.core.util.binning.numeric.NumericBin) Closure(org.knime.core.util.binning.auto.pmml.Closure) PMMLInterval(org.knime.core.util.binning.auto.pmml.PMMLInterval)

Aggregations

Closure (org.knime.core.util.binning.auto.pmml.Closure)1 PMMLInterval (org.knime.core.util.binning.auto.pmml.PMMLInterval)1 NumericBin (org.knime.core.util.binning.numeric.NumericBin)1