use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.
the class AutoBinnerApplyNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
PMMLPreprocPortObject pmmlPort = (PMMLPreprocPortObject) ((PortObjectInput) inputs[0]).getPortObject();
validatePMMLPort(pmmlPort);
PMMLPreprocDiscretize op = (PMMLPreprocDiscretize) pmmlPort.getOperations().get(0);
AutoBinnerApply applier = new AutoBinnerApply();
ColumnRearranger core = applier.getRearranger(op, (DataTableSpec) inSpecs[1]);
StreamableFunction func = core.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.
the class AutoBinner method init.
/**
* Initialize instance and check if settings are consistent.
*/
private void init(final DataTableSpec inSpec) throws InvalidSettingsException {
PMMLPreprocDiscretize op = createDisretizeOp(null);
AutoBinnerApply applier = new AutoBinnerApply();
m_tableOutSpec = applier.getOutputSpec(op, inSpec);
m_pmmlOutSpec = new PMMLDiscretizePreprocPortObjectSpec(op);
}
use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.
the class DBAutoBinnerNodeModel method createPMMLPortObject.
private PMMLPortObject createPMMLPortObject(final DatabasePortObjectSpec inSpec, final DatabaseQueryConnectionSettings connectionSettings, final ExecutionMonitor exec) throws InvalidSettingsException {
DataTableSpec dataTableSpec = inSpec.getDataTableSpec();
DBAutoBinner autoBinner = new DBAutoBinner(m_settings, dataTableSpec);
PMMLPreprocDiscretize pMMLPrepocDiscretize;
try {
pMMLPrepocDiscretize = autoBinner.createPMMLPrepocDiscretize(getCredentialsProvider(), connectionSettings, dataTableSpec);
PMMLPortObject pmmlPortObject = DBAutoBinner.translate(pMMLPrepocDiscretize, dataTableSpec);
return pmmlPortObject;
} catch (SQLException e) {
throw new InvalidSettingsException("Could not retrieve boundaries from database. Exception: " + e.getMessage(), e);
}
}
use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize in project knime-core by knime.
the class AutoBinner method init.
/**
* Initialize instance and check if settings are consistent.
*/
private void init(final DataTableSpec inSpec) throws InvalidSettingsException {
PMMLPreprocDiscretize op = createDisretizeOp(null);
AutoBinnerApply applier = new AutoBinnerApply();
m_tableOutSpec = applier.getOutputSpec(op, inSpec);
m_pmmlOutSpec = new PMMLDiscretizePreprocPortObjectSpec(op);
}
use of org.knime.base.node.preproc.autobinner.pmml.PMMLPreprocDiscretize 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;
}
Aggregations