Search in sources :

Example 1 with PMMLNormalizeTranslator

use of org.knime.base.data.normalize.PMMLNormalizeTranslator in project knime-core by knime.

the class NormalizerPMMLApplyNodeModel 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];
    PMMLNormalizeTranslator translator = new PMMLNormalizeTranslator();
    translator.initializeFrom(model.getDerivedFields());
    AffineTransConfiguration config = getAffineTrans(translator.getAffineTransConfig());
    if (config.getNames().length == 0) {
        throw new IllegalArgumentException("No normalization configuration " + "found.");
    }
    AffineTransTable t = new AffineTransTable(table, config);
    BufferedDataTable bdt = exec.createBufferedDataTable(t, exec);
    if (t.getErrorMessage() != null) {
        setWarningMessage(t.getErrorMessage());
    }
    return new PortObject[] { model, bdt };
}
Also used : PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) BufferedDataTable(org.knime.core.node.BufferedDataTable) AffineTransTable(org.knime.base.data.normalize.AffineTransTable) AffineTransConfiguration(org.knime.base.data.normalize.AffineTransConfiguration) PMMLNormalizeTranslator(org.knime.base.data.normalize.PMMLNormalizeTranslator) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject)

Example 2 with PMMLNormalizeTranslator

use of org.knime.base.data.normalize.PMMLNormalizeTranslator in project knime-core by knime.

the class AbstractNormalizerPMMLNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
    CalculationResult result = calculate(inObjects, exec);
    BufferedDataTable outTable = result.getDataTable();
    // the optional PMML in port (can be null)
    PMMLPortObject inPMMLPort = m_hasModelIn ? (PMMLPortObject) inObjects[1] : null;
    PMMLNormalizeTranslator trans = new PMMLNormalizeTranslator(result.getConfig(), new DerivedFieldMapper(inPMMLPort));
    DataTableSpec dataTableSpec = (DataTableSpec) inObjects[0].getSpec();
    PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, dataTableSpec);
    PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort);
    outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
    return new PortObject[] { outTable, outPMMLPort };
}
Also used : DerivedFieldMapper(org.knime.core.node.port.pmml.preproc.DerivedFieldMapper) DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) BufferedDataTable(org.knime.core.node.BufferedDataTable) PMMLNormalizeTranslator(org.knime.base.data.normalize.PMMLNormalizeTranslator) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Aggregations

PMMLNormalizeTranslator (org.knime.base.data.normalize.PMMLNormalizeTranslator)2 BufferedDataTable (org.knime.core.node.BufferedDataTable)2 PortObject (org.knime.core.node.port.PortObject)2 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)2 AffineTransConfiguration (org.knime.base.data.normalize.AffineTransConfiguration)1 AffineTransTable (org.knime.base.data.normalize.AffineTransTable)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)1 DerivedFieldMapper (org.knime.core.node.port.pmml.preproc.DerivedFieldMapper)1