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;
}
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;
}
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;
}
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;
}
Aggregations