use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.
the class CategoryToNumberNodeModel 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 {
ColumnRearranger cr = createRearranger((DataTableSpec) inSpecs[0]);
cr.createStreamableFunction(0, 0).runFinal(inputs, outputs, exec);
// the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = null;
if (m_pmmlInEnabled && inputs[1] != null) {
inPMMLPort = (PMMLPortObject) ((PortObjectInput) inputs[1]).getPortObject();
}
PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, cr.createSpec());
PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort);
for (CategoryToNumberCellFactory factory : m_factories) {
PMMLMapValuesTranslator trans = new PMMLMapValuesTranslator(factory.getConfig(), new DerivedFieldMapper(inPMMLPort));
outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
}
PortObjectOutput portObjectOutput = (PortObjectOutput) outputs[1];
portObjectOutput.setPortObject(outPMMLPort);
}
};
}
use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.
the class CategoryToNumberApplyNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
PMMLPortObject model = (PMMLPortObject) inData[0];
BufferedDataTable table = (BufferedDataTable) inData[1];
ColumnRearranger rearranger = createRearranger(table.getDataTableSpec(), model);
if (null == rearranger) {
throw new IllegalArgumentException("No map values configuration found.");
}
BufferedDataTable outTable = exec.createColumnRearrangeTable(table, rearranger, exec);
return new PortObject[] { model, outTable };
}
use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.
the class NumberToCategoryApplyNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
PMMLPortObject model = (PMMLPortObject) inData[0];
BufferedDataTable table = (BufferedDataTable) inData[1];
ColumnRearranger rearranger = createRearranger(table.getDataTableSpec(), model);
if (null == rearranger) {
throw new IllegalArgumentException("No map values configuration found.");
}
BufferedDataTable outTable = exec.createColumnRearrangeTable(table, rearranger, exec);
return new PortObject[] { model, outTable };
}
use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.
the class DataColumnSpecFilterPMMLNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
final ColumnRearranger corea = createColumnRearranger((DataTableSpec) inSpecs[0]);
final StreamableFunction fct = corea.createStreamableFunction();
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
// execute streamable in- and outport (0)
fct.init(exec);
fct.runFinal(inputs, outputs, exec);
fct.finish();
DataTableSpec outSpec = corea.createSpec();
// pmml ports
PMMLPortObject pmmlIn = (PMMLPortObject) ((PortObjectInput) inputs[1]).getPortObject();
final PMMLPortObject pmmlOut = createPMMLOut(pmmlIn, outSpec, getFilterResult((DataTableSpec) inSpecs[0]));
((PortObjectOutput) outputs[1]).setPortObject(pmmlOut);
}
};
}
use of org.knime.core.node.port.pmml.PMMLPortObject in project knime-core by knime.
the class One2ManyCol2PMMLNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
BufferedDataTable inData = (BufferedDataTable) inObjects[0];
DataTableSpec dts = inData.getDataTableSpec();
checkColumnsSpecs(dts);
String[] includes = m_includedColumns.applyTo(dts).getIncludes();
One2ManyCellFactory cellFactory = new One2ManyCellFactory(dts, Arrays.asList(includes), m_appendOrgColName);
BufferedDataTable outData = exec.createColumnRearrangeTable(inData, createRearranger(dts, cellFactory), exec);
if (m_pmmlOutEnabled) {
// the optional PMML in port (can be null)
PMMLPortObject inPMMLPort = m_pmmlInEnabled ? (PMMLPortObject) inObjects[1] : null;
PMMLOne2ManyTranslator trans = new PMMLOne2ManyTranslator(cellFactory.getColumnMapping(), new DerivedFieldMapper(inPMMLPort));
PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, outData.getDataTableSpec());
PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort);
outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
return new PortObject[] { outData, outPMMLPort };
} else {
return new PortObject[] { outData };
}
}
Aggregations