Search in sources :

Example 61 with PMMLPortObjectSpecCreator

use of org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator in project knime-core by knime.

the class RuleEngine2PortsNodeModel method computeFinalOutputSpecs.

/**
 * {@inheritDoc}
 */
@Override
public PortObjectSpec[] computeFinalOutputSpecs(final StreamableOperatorInternals internals, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    final StreamInternalWithPortObject sipo = (StreamInternalWithPortObject) internals;
    final DataTableSpec tableSpec = sipo.getTableSpec();
    return new PortObjectSpec[] { tableSpec, sipo.getObject() != null ? new PMMLPortObjectSpecCreator(tableSpec).createSpec() : InactiveBranchPortObject.INSTANCE.getSpec() };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Example 62 with PMMLPortObjectSpecCreator

use of org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator in project knime-core by knime.

the class DecisionTreeLearnerNodeModel method createPMMLPortObjectSpec.

private PMMLPortObjectSpec createPMMLPortObjectSpec(final PMMLPortObjectSpec modelSpec, final DataTableSpec spec) {
    String targetCol = m_classifyColumn.getStringValue();
    List<String> learnCols = new LinkedList<String>();
    for (int i = 0; i < spec.getNumColumns(); i++) {
        DataColumnSpec columnSpec = spec.getColumnSpec(i);
        String col = columnSpec.getName();
        if (!col.equals(targetCol) && (columnSpec.getType().isCompatible(DoubleValue.class) || columnSpec.getType().isCompatible(NominalValue.class) && (!m_skipColumns.getBooleanValue() || columnSpec.getDomain().hasValues()))) {
            learnCols.add(spec.getColumnSpec(i).getName());
        }
    }
    String[] usedCols = learnCols.toArray(new String[learnCols.size() + 1]);
    usedCols[usedCols.length - 1] = targetCol;
    PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(modelSpec, spec);
    pmmlSpecCreator.setLearningColsNames(learnCols);
    pmmlSpecCreator.setTargetColName(targetCol);
    return pmmlSpecCreator.createSpec();
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) DoubleValue(org.knime.core.data.DoubleValue) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) LinkedList(java.util.LinkedList) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Aggregations

PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)62 DataTableSpec (org.knime.core.data.DataTableSpec)35 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)24 DataColumnSpec (org.knime.core.data.DataColumnSpec)21 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)21 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)19 BufferedDataTable (org.knime.core.node.BufferedDataTable)15 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)14 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)13 PortObject (org.knime.core.node.port.PortObject)13 DerivedFieldMapper (org.knime.core.node.port.pmml.preproc.DerivedFieldMapper)11 ArrayList (java.util.ArrayList)10 DoubleValue (org.knime.core.data.DoubleValue)10 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)9 LinkedList (java.util.LinkedList)6 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)6 HashSet (java.util.HashSet)4 LinkedHashSet (java.util.LinkedHashSet)4 DataCell (org.knime.core.data.DataCell)3 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)3