Search in sources :

Example 66 with PMMLPortObjectSpec

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

the class NaiveBayesPredictorNodeDialog2 method extractTargetColumn.

/**
 * {@inheritDoc}
 */
@Override
protected void extractTargetColumn(final PortObjectSpec[] specs) {
    if (specs[0] instanceof PMMLPortObjectSpec) {
        PMMLPortObjectSpec spec = (PMMLPortObjectSpec) specs[0];
        final List<DataColumnSpec> targetCols = spec.getTargetCols();
        if (targetCols.size() != 1) {
            throw new IllegalStateException("No valid class column found");
        }
        final DataColumnSpec targetColumn = targetCols.get(0);
        setLastTargetColumn(targetColumn);
    } else {
        throw new IllegalStateException(specs[0].getClass().toString());
    }
}
Also used : PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Example 67 with PMMLPortObjectSpec

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

the class One2ManyCol2PMMLNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    DataTableSpec inDataSpec = (DataTableSpec) inSpecs[0];
    m_appendOrgColName = false;
    String[] includes = m_includedColumns.applyTo(inDataSpec).getIncludes();
    if (includes.length <= 0) {
        setWarningMessage("No columns to transfrom selected. Will have no effect!");
    }
    // check if the values are present in the current spec
    if (includes.length > 0) {
        checkColumnsSpecs(inDataSpec);
    }
    CellFactory cellFactory = new One2ManyCellFactory(inDataSpec, Arrays.asList(includes), m_appendOrgColName);
    ColumnRearranger rearranger = createRearranger(inDataSpec, cellFactory);
    if (m_pmmlOutEnabled) {
        PMMLPortObjectSpec pmmlSpec = m_pmmlInEnabled ? (PMMLPortObjectSpec) inSpecs[1] : null;
        PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, inDataSpec);
        return new PortObjectSpec[] { rearranger.createSpec(), pmmlSpecCreator.createSpec() };
    } else {
        return new PortObjectSpec[] { rearranger.createSpec() };
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) One2ManyCellFactory(org.knime.base.node.preproc.columntrans2.One2ManyCellFactory) One2ManyCellFactory(org.knime.base.node.preproc.columntrans2.One2ManyCellFactory) CellFactory(org.knime.core.data.container.CellFactory) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Example 68 with PMMLPortObjectSpec

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

the class AbstractNormalizerPMMLNodeModel method prepareConfigure.

/**
 * @param inSpecs An array of DataTableSpecs (as many as this model has
 *            inputs).
 * @return An array of DataTableSpecs (as many as this model has outputs)
 *
 * @throws InvalidSettingsException if the <code>#configure()</code> failed,
 *             that is, the settings are inconsistent with given
 *             DataTableSpec elements.
 */
@Override
protected PortObjectSpec[] prepareConfigure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    DataTableSpec spec = (DataTableSpec) inSpecs[0];
    PMMLPortObjectSpecCreator pmmlSpecCreator;
    if (m_hasModelIn) {
        PMMLPortObjectSpec pmmlSpec = (PMMLPortObjectSpec) inSpecs[1];
        // extract selected numeric columns
        updateNumericColumnSelection(spec);
        if (getMode() == NONORM_MODE) {
            return new PortObjectSpec[] { spec, pmmlSpec };
        }
        pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, spec);
    } else {
        // extract selected numeric columns
        updateNumericColumnSelection(spec);
        if (getMode() == NONORM_MODE) {
            return new PortObjectSpec[] { spec };
        }
        pmmlSpecCreator = new PMMLPortObjectSpecCreator(spec);
    }
    return new PortObjectSpec[] { Normalizer2.generateNewSpec(spec, getColumns()), pmmlSpecCreator.createSpec() };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Example 69 with PMMLPortObjectSpec

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

the class CategoryToNumberNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    DataTableSpec inSpec = (DataTableSpec) inSpecs[0];
    List<String> inputCols = new ArrayList<String>();
    for (DataColumnSpec column : inSpec) {
        if (column.getType().isCompatible(StringValue.class)) {
            inputCols.add(column.getName());
        }
    }
    FilterResult filter = m_settings.getFilterConfiguration().applyTo(inSpec);
    String[] rmFromIncl = filter.getRemovedFromIncludes();
    if (m_settings.getFilterConfiguration().isEnforceInclusion() && rmFromIncl.length != 0) {
        throw new InvalidSettingsException("Input table does not contain the following selected column(s): " + ConvenienceMethods.getShortStringFrom(new HashSet<String>(Arrays.asList(rmFromIncl)), 3));
    }
    m_included = filter.getIncludes();
    if (m_included.length == 0) {
        setWarningMessage("No columns selected.");
    }
    ColumnRearranger rearranger = createRearranger(inSpec);
    PMMLPortObjectSpec pmmlSpec = m_pmmlInEnabled ? (PMMLPortObjectSpec) inSpecs[1] : null;
    PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, inSpec);
    pmmlSpecCreator.addPreprocColNames(inputCols);
    return new PortObjectSpec[] { rearranger.createSpec(), pmmlSpecCreator.createSpec() };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) ArrayList(java.util.ArrayList) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FilterResult(org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Example 70 with PMMLPortObjectSpec

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

the class DecTreePredictorNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    PMMLPortObjectSpec treeSpec = (PMMLPortObjectSpec) inSpecs[INMODELPORT];
    DataTableSpec inSpec = (DataTableSpec) inSpecs[1];
    for (String learnColName : treeSpec.getLearningFields()) {
        if (!inSpec.containsName(learnColName)) {
            throw new InvalidSettingsException("Learning column \"" + learnColName + "\" not found in input " + "data to be predicted");
        }
    }
    return new PortObjectSpec[] { createOutTableSpec(inSpecs) };
}
Also used : PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec)

Aggregations

PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)77 DataTableSpec (org.knime.core.data.DataTableSpec)57 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)40 DataColumnSpec (org.knime.core.data.DataColumnSpec)31 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)30 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)23 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)23 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)22 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)20 BufferedDataTable (org.knime.core.node.BufferedDataTable)15 PortObject (org.knime.core.node.port.PortObject)12 DataCell (org.knime.core.data.DataCell)10 DoubleValue (org.knime.core.data.DoubleValue)10 DataRow (org.knime.core.data.DataRow)8 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)7 ArrayList (java.util.ArrayList)6 LinkedList (java.util.LinkedList)6 DataColumnDomain (org.knime.core.data.DataColumnDomain)6 DoubleCell (org.knime.core.data.def.DoubleCell)6 IOException (java.io.IOException)4