Search in sources :

Example 1 with SotaPortObjectSpec

use of org.knime.base.node.mine.sota.SotaPortObjectSpec in project knime-core by knime.

the class SotaPredictorNodeFactory method createNodeDialogPane.

/**
 * {@inheritDoc}
 */
@Override
protected NodeDialogPane createNodeDialogPane() {
    return new PredictorNodeDialog(SotaPredictorNodeModel.createAppendProbabilities()) {

        /**
         * {@inheritDoc}
         */
        @Override
        protected void extractTargetColumn(final PortObjectSpec[] specs) {
            if (specs[0] instanceof SotaPortObjectSpec) {
                final SotaPortObjectSpec sotaSpec = (SotaPortObjectSpec) specs[0];
                final DataColumnSpec classColumnSpec = sotaSpec.getClassColumnSpec();
                setLastTargetColumn(classColumnSpec == null ? new DataColumnSpecCreator("No class", StringCell.TYPE).createSpec() : classColumnSpec);
            } else {
                throw new IllegalArgumentException("Wrong input: " + specs[0].getClass());
            }
        }
    };
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) SotaPortObjectSpec(org.knime.base.node.mine.sota.SotaPortObjectSpec) PredictorNodeDialog(org.knime.base.node.mine.util.PredictorNodeDialog)

Example 2 with SotaPortObjectSpec

use of org.knime.base.node.mine.sota.SotaPortObjectSpec in project knime-core by knime.

the class SotaPredictorNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    if (!(inData[1] instanceof BufferedDataTable)) {
        throw new IllegalArgumentException("Given inport object at " + "index 0 is not a BufferedDataTable!");
    } else if (!(inData[0] instanceof SotaPortObject)) {
        throw new IllegalArgumentException("Given inport object at " + "index 1 is not a SotaPortObject");
    }
    BufferedDataTable bdt = (BufferedDataTable) inData[1];
    SotaPortObject spo = (SotaPortObject) inData[0];
    exec.checkCanceled();
    // build data table to use
    int[] indicesOfIncludedCols = new int[bdt.getDataTableSpec().getNumColumns()];
    for (int i = 0; i < bdt.getDataTableSpec().getNumColumns(); i++) {
        indicesOfIncludedCols[i] = i;
    }
    exec.checkCanceled();
    ColumnRearranger cr = new ColumnRearranger(bdt.getDataTableSpec());
    final SotaPortObjectSpec sotaSpec = (SotaPortObjectSpec) spo.getSpec();
    cr.append(new SotaPredictorCellFactory(spo.getSotaRoot(), indicesOfIncludedCols, spo.getDistance(), m_appendProbs.getBooleanValue(), sotaSpec.getClassColumnSpec(), m_probSuffix.getStringValue(), createOutColSpecs(sotaSpec)));
    return new BufferedDataTable[] { exec.createColumnRearrangeTable(bdt, cr, exec) };
}
Also used : ColumnRearranger(org.knime.core.data.container.ColumnRearranger) SotaPortObject(org.knime.base.node.mine.sota.SotaPortObject) SotaPortObjectSpec(org.knime.base.node.mine.sota.SotaPortObjectSpec) BufferedDataTable(org.knime.core.node.BufferedDataTable)

Aggregations

SotaPortObjectSpec (org.knime.base.node.mine.sota.SotaPortObjectSpec)2 SotaPortObject (org.knime.base.node.mine.sota.SotaPortObject)1 PredictorNodeDialog (org.knime.base.node.mine.util.PredictorNodeDialog)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)1 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)1 BufferedDataTable (org.knime.core.node.BufferedDataTable)1