Search in sources :

Example 1 with DisretizeConfiguration

use of org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration in project knime-core by knime.

the class AutoBinner method createDisretizeOp.

private PMMLPreprocDiscretize createDisretizeOp(final Map<String, double[]> edgesMap) {
    Map<String, List<PMMLDiscretizeBin>> binMap = createBins(edgesMap);
    List<String> names = new ArrayList<String>();
    Map<String, PMMLDiscretize> discretize = new HashMap<String, PMMLDiscretize>();
    for (String target : m_settings.getTargetColumn()) {
        String binnedCol = m_settings.getReplaceColumn() ? target : target + " [Binned]";
        names.add(binnedCol);
        discretize.put(binnedCol, new PMMLDiscretize(target, binMap.get(target)));
    }
    DisretizeConfiguration config = new DisretizeConfiguration(names, discretize);
    PMMLPreprocDiscretize op = new PMMLPreprocDiscretize(config);
    return op;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DisretizeConfiguration(org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration) ArrayList(java.util.ArrayList) PMMLDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretize) ArrayList(java.util.ArrayList) List(java.util.List) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)

Example 2 with DisretizeConfiguration

use of org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration in project knime-core by knime.

the class AutoBinner method createDisretizeOp.

private PMMLPreprocDiscretize createDisretizeOp(final Map<String, double[]> edgesMap) {
    Map<String, List<PMMLDiscretizeBin>> binMap = createBins(edgesMap);
    List<String> names = new ArrayList<String>();
    Map<String, PMMLDiscretize> discretize = new HashMap<String, PMMLDiscretize>();
    for (String target : m_settings.getTargetColumn()) {
        String binnedCol = m_settings.getReplaceColumn() ? target : target + " [Binned]";
        names.add(binnedCol);
        discretize.put(binnedCol, new PMMLDiscretize(target, binMap.get(target)));
    }
    DisretizeConfiguration config = new DisretizeConfiguration(names, discretize);
    PMMLPreprocDiscretize op = new PMMLPreprocDiscretize(config);
    return op;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DisretizeConfiguration(org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration) ArrayList(java.util.ArrayList) PMMLDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretize) ArrayList(java.util.ArrayList) List(java.util.List) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)

Example 3 with DisretizeConfiguration

use of org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration in project knime-core by knime.

the class AutoBinnerApply method getRearranger.

/**
 * Create {@link ColumnRearranger}.
 * @param op {@link PMMLPreprocDiscretize} operation
 * @param inTable the input data table
 * @throws InvalidSettingsException when settings are inconsistent
 */
ColumnRearranger getRearranger(final PMMLPreprocDiscretize op, final DataTableSpec dataSpec) throws InvalidSettingsException {
    DisretizeConfiguration config = op.getConfiguration();
    // Check if columns to discretize exist
    for (String name : config.getNames()) {
        String toBin = config.getDiscretize(name).getField();
        if (!dataSpec.containsName(toBin)) {
            throw new InvalidSettingsException("Column " + "\"" + toBin + "\"" + "is missing in the input table.");
        }
    }
    ColumnRearranger rearranger = new ColumnRearranger(dataSpec);
    for (String name : config.getNames()) {
        int colIdx = dataSpec.findColumnIndex(config.getDiscretize(name).getField());
        assert colIdx >= 0;
        if (dataSpec.containsName(name)) {
            rearranger.replace(new BinningCellFactory(name, colIdx, config.getDiscretize(name)), name);
        } else {
            rearranger.append(new BinningCellFactory(name, colIdx, config.getDiscretize(name)));
        }
    }
    return rearranger;
}
Also used : ColumnRearranger(org.knime.core.data.container.ColumnRearranger) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DisretizeConfiguration(org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration)

Example 4 with DisretizeConfiguration

use of org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration in project knime-core by knime.

the class AutoBinner method createDisretizeOp.

/**
 * @param edgesMap the boundary map
 * @return the {@link PMMLPreprocDiscretize} model
 */
protected PMMLPreprocDiscretize createDisretizeOp(final Map<String, double[]> edgesMap) {
    Map<String, List<PMMLDiscretizeBin>> binMap = createBins(edgesMap);
    List<String> names = new ArrayList<String>();
    Map<String, PMMLDiscretize> discretize = new HashMap<String, PMMLDiscretize>();
    for (String target : m_included) {
        String binnedCol = m_settings.getReplaceColumn() ? target : target + " [Binned]";
        names.add(binnedCol);
        discretize.put(binnedCol, new PMMLDiscretize(target, binMap.get(target)));
    }
    DisretizeConfiguration config = new DisretizeConfiguration(names, discretize);
    PMMLPreprocDiscretize op = new PMMLPreprocDiscretize(config);
    return op;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DisretizeConfiguration(org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration) ArrayList(java.util.ArrayList) PMMLDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretize) ArrayList(java.util.ArrayList) List(java.util.List) PMMLPreprocDiscretize(org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)

Aggregations

DisretizeConfiguration (org.knime.base.node.preproc.autobinner.pmml.DisretizeConfiguration)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 PMMLDiscretize (org.knime.base.node.preproc.autobinner.pmml.PMMLDiscretize)3 PMMLPreprocDiscretize (org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize)3 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1