Search in sources :

Example 6 with PortObjectSpec

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

the class NewToOldTimeNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    return new StreamableOperator() {

        @Override
        public StreamableOperatorInternals saveInternals() {
            return null;
        }

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            final RowInput in = (RowInput) inputs[0];
            final RowOutput out = (RowOutput) outputs[0];
            final DataTableSpec inSpec = in.getDataTableSpec();
            String[] includeList = m_colSelect.applyTo(inSpec).getIncludes();
            final int[] includeIndeces = Arrays.stream(includeList).mapToInt(s -> inSpec.findColumnIndex(s)).toArray();
            DataRow row;
            while ((row = in.poll()) != null) {
                exec.checkCanceled();
                DataCell[] datacells = new DataCell[includeIndeces.length];
                for (int i = 0; i < includeIndeces.length; i++) {
                    if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
                        final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includeList[i], DateAndTimeCell.TYPE);
                        final ConvertTimeCellFactory cellFac = new ConvertTimeCellFactory(dataColumnSpecCreator.createSpec(), includeIndeces[i]);
                        datacells[i] = cellFac.getCells(row)[0];
                    } else {
                        final DataColumnSpec dataColSpec = new UniqueNameGenerator(inSpec).newColumn(includeList[i] + m_suffix.getStringValue(), DateAndTimeCell.TYPE);
                        final ConvertTimeCellFactory cellFac = new ConvertTimeCellFactory(dataColSpec, includeIndeces[i]);
                        datacells[i] = cellFac.getCells(row)[0];
                    }
                }
                if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
                    out.push(new ReplacedColumnsDataRow(row, datacells, includeIndeces));
                } else {
                    out.push(new AppendedColumnRow(row, datacells));
                }
            }
            in.close();
            out.close();
        }
    };
}
Also used : Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) ZonedDateTime(java.time.ZonedDateTime) UniqueNameGenerator(org.knime.core.util.UniqueNameGenerator) LocalDateTime(java.time.LocalDateTime) AppendedColumnRow(org.knime.core.data.append.AppendedColumnRow) LocalTimeValue(org.knime.core.data.time.localtime.LocalTimeValue) LocalDateValue(org.knime.core.data.time.localdate.LocalDateValue) ExecutionContext(org.knime.core.node.ExecutionContext) SingleCellFactory(org.knime.core.data.container.SingleCellFactory) StreamableOperatorInternals(org.knime.core.node.streamable.StreamableOperatorInternals) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) LocalTime(java.time.LocalTime) ZoneOffset(java.time.ZoneOffset) DataCell(org.knime.core.data.DataCell) ZonedDateTimeValue(org.knime.core.data.time.zoneddatetime.ZonedDateTimeValue) PortInput(org.knime.core.node.streamable.PortInput) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) PartitionInfo(org.knime.core.node.streamable.PartitionInfo) RowInput(org.knime.core.node.streamable.RowInput) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) SettingsModelColumnFilter2(org.knime.core.node.defaultnodesettings.SettingsModelColumnFilter2) OutputPortRole(org.knime.core.node.streamable.OutputPortRole) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) NodeModel(org.knime.core.node.NodeModel) File(java.io.File) DataRow(org.knime.core.data.DataRow) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) PortOutput(org.knime.core.node.streamable.PortOutput) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) TimeUnit(java.util.concurrent.TimeUnit) BufferedDataTable(org.knime.core.node.BufferedDataTable) LocalDateTimeValue(org.knime.core.data.time.localdatetime.LocalDateTimeValue) InputPortRole(org.knime.core.node.streamable.InputPortRole) LocalDate(java.time.LocalDate) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) DateAndTimeCell(org.knime.core.data.date.DateAndTimeCell) RowOutput(org.knime.core.node.streamable.RowOutput) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) RowInput(org.knime.core.node.streamable.RowInput) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) DataRow(org.knime.core.data.DataRow) UniqueNameGenerator(org.knime.core.util.UniqueNameGenerator) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataCell(org.knime.core.data.DataCell) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) AppendedColumnRow(org.knime.core.data.append.AppendedColumnRow)

Example 7 with PortObjectSpec

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

the class DateTimeToStringNodeModel 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 {
            final RowInput in = (RowInput) inputs[0];
            final RowOutput out = (RowOutput) outputs[0];
            final DataTableSpec inSpec = in.getDataTableSpec();
            final String[] includeList = m_colSelect.applyTo(inSpec).getIncludes();
            final int[] includeIndeces = Arrays.stream(m_colSelect.applyTo(inSpec).getIncludes()).mapToInt(s -> inSpec.findColumnIndex(s)).toArray();
            final boolean isReplace = m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE);
            DataRow row;
            while ((row = in.poll()) != null) {
                exec.checkCanceled();
                DataCell[] datacells = new DataCell[includeIndeces.length];
                for (int i = 0; i < includeIndeces.length; i++) {
                    if (isReplace) {
                        final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includeList[i], StringCell.TYPE);
                        final TimeToStringCellFactory cellFac = new TimeToStringCellFactory(dataColumnSpecCreator.createSpec(), includeIndeces[i]);
                        datacells[i] = cellFac.getCell(row);
                    } else {
                        final DataColumnSpec dataColSpec = new UniqueNameGenerator(inSpec).newColumn(includeList[i] + m_suffix.getStringValue(), StringCell.TYPE);
                        final TimeToStringCellFactory cellFac = new TimeToStringCellFactory(dataColSpec, includeIndeces[i]);
                        datacells[i] = cellFac.getCell(row);
                    }
                }
                if (isReplace) {
                    out.push(new ReplacedColumnsDataRow(row, datacells, includeIndeces));
                } else {
                    out.push(new AppendedColumnRow(row, datacells));
                }
            }
            in.close();
            out.close();
        }
    };
}
Also used : Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) UniqueNameGenerator(org.knime.core.util.UniqueNameGenerator) LocalDateValue(org.knime.core.data.time.localdate.LocalDateValue) LocalDateTimeCellFactory(org.knime.core.data.time.localdatetime.LocalDateTimeCellFactory) DataColumnSpec(org.knime.core.data.DataColumnSpec) Locale(java.util.Locale) ChangeListener(javax.swing.event.ChangeListener) ZonedDateTimeValue(org.knime.core.data.time.zoneddatetime.ZonedDateTimeValue) ChangeEvent(javax.swing.event.ChangeEvent) PortInput(org.knime.core.node.streamable.PortInput) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) PartitionInfo(org.knime.core.node.streamable.PartitionInfo) Collection(java.util.Collection) Set(java.util.Set) SettingsModelColumnFilter2(org.knime.core.node.defaultnodesettings.SettingsModelColumnFilter2) NodeModel(org.knime.core.node.NodeModel) LocalDateCell(org.knime.core.data.time.localdate.LocalDateCell) BufferedDataTable(org.knime.core.node.BufferedDataTable) InputPortRole(org.knime.core.node.streamable.InputPortRole) StringHistory(org.knime.core.node.util.StringHistory) LocalDateTimeCell(org.knime.core.data.time.localdatetime.LocalDateTimeCell) RowOutput(org.knime.core.node.streamable.RowOutput) DataTableSpec(org.knime.core.data.DataTableSpec) ZonedDateTimeCell(org.knime.core.data.time.zoneddatetime.ZonedDateTimeCell) AppendedColumnRow(org.knime.core.data.append.AppendedColumnRow) LocalTimeValue(org.knime.core.data.time.localtime.LocalTimeValue) ExecutionContext(org.knime.core.node.ExecutionContext) LocaleUtils(org.apache.commons.lang3.LocaleUtils) SingleCellFactory(org.knime.core.data.container.SingleCellFactory) ZonedDateTimeCellFactory(org.knime.core.data.time.zoneddatetime.ZonedDateTimeCellFactory) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) DataCell(org.knime.core.data.DataCell) LinkedHashSet(java.util.LinkedHashSet) LocalDateCellFactory(org.knime.core.data.time.localdate.LocalDateCellFactory) LocalTimeCellFactory(org.knime.core.data.time.localtime.LocalTimeCellFactory) StringCellFactory(org.knime.core.data.def.StringCell.StringCellFactory) RowInput(org.knime.core.node.streamable.RowInput) LocalTimeCell(org.knime.core.data.time.localtime.LocalTimeCell) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) OutputPortRole(org.knime.core.node.streamable.OutputPortRole) UnsupportedTemporalTypeException(java.time.temporal.UnsupportedTemporalTypeException) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) File(java.io.File) DataRow(org.knime.core.data.DataRow) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) PortOutput(org.knime.core.node.streamable.PortOutput) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) LocalDateTimeValue(org.knime.core.data.time.localdatetime.LocalDateTimeValue) MissingCell(org.knime.core.data.MissingCell) DateTimeFormatter(java.time.format.DateTimeFormatter) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StringCell(org.knime.core.data.def.StringCell) DataType(org.knime.core.data.DataType) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) RowInput(org.knime.core.node.streamable.RowInput) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) DataRow(org.knime.core.data.DataRow) UniqueNameGenerator(org.knime.core.util.UniqueNameGenerator) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataCell(org.knime.core.data.DataCell) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) AppendedColumnRow(org.knime.core.data.append.AppendedColumnRow)

Example 8 with PortObjectSpec

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

the class NaiveBayesPredictorNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    // check the input data
    assert (inSpecs != null && inSpecs.length == 2 && inSpecs[DATA_IN_PORT] != null && inSpecs[MODEL_IN_PORT] != null);
    final PortObjectSpec modelObject = inSpecs[MODEL_IN_PORT];
    if (!(modelObject instanceof NaiveBayesPortObjectSpec)) {
        throw new IllegalArgumentException("Invalid input data");
    }
    final DataTableSpec trainingSpec = ((NaiveBayesPortObjectSpec) modelObject).getTableSpec();
    final DataColumnSpec classColumn = ((NaiveBayesPortObjectSpec) modelObject).getClassColumn();
    if (trainingSpec == null) {
        throw new InvalidSettingsException("No model spec available");
    }
    final PortObjectSpec inSpec = inSpecs[DATA_IN_PORT];
    if (!(inSpec instanceof DataTableSpec)) {
        throw new IllegalArgumentException("TableSpec must not be null");
    }
    final DataTableSpec spec = (DataTableSpec) inSpec;
    // check the input data for columns with the wrong name or wrong type
    final List<String> unknownCols = check4UnknownCols(trainingSpec, spec);
    if (unknownCols.size() >= spec.getNumColumns()) {
        setWarningMessage("No known attribute columns found use " + "class prior probability to predict the class membership");
    } else if (unknownCols.size() == 1) {
        setWarningMessage("Input column " + unknownCols.get(0) + " is unknown and will be skipped.");
    } else if (unknownCols.size() > 1) {
        final StringBuilder buf = new StringBuilder();
        buf.append("The following input columns are unknown and " + "will be skipped: ");
        for (int i = 0, length = unknownCols.size(); i < length; i++) {
            if (i != 0) {
                buf.append(", ");
            }
            if (i > 3) {
                buf.append("...");
                break;
            }
            buf.append(unknownCols.get(i));
        }
        setWarningMessage(buf.toString());
    }
    // check if the learned model contains columns which are not in the
    // input data
    final List<String> missingInputCols = check4MissingCols(trainingSpec, classColumn.getName(), spec);
    if (missingInputCols.size() == 1) {
        setWarningMessage("Attribute " + missingInputCols.get(0) + " is missing in the input data");
    } else if (missingInputCols.size() > 1) {
        final StringBuilder buf = new StringBuilder();
        buf.append("The following attributes are missing in " + "the input data: ");
        for (int i = 0, length = missingInputCols.size(); i < length; i++) {
            if (i != 0) {
                buf.append(", ");
            }
            if (i > 3) {
                buf.append("...");
                break;
            }
            buf.append(missingInputCols.get(i));
        }
        setWarningMessage(buf.toString());
    }
    final DataColumnSpec resultColSpecs = NaiveBayesCellFactory.createResultColSpecs(classColumn, spec, m_inclProbVals.getBooleanValue());
    if (resultColSpecs != null) {
        return new PortObjectSpec[] { AppendedColumnTable.getTableSpec(spec, resultColSpecs) };
    }
    return null;
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NaiveBayesPortObjectSpec(org.knime.base.node.mine.bayes.naivebayes.port.NaiveBayesPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) NaiveBayesPortObjectSpec(org.knime.base.node.mine.bayes.naivebayes.port.NaiveBayesPortObjectSpec)

Example 9 with PortObjectSpec

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

the class NaiveBayesLearnerNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    // check the internal variables if they are valid
    final String classColumn = m_classifyColumnName.getStringValue();
    if (classColumn == null || classColumn.length() < 1) {
        throw new InvalidSettingsException("Please define the classification column");
    }
    final PortObjectSpec inSpec = inSpecs[TRAINING_DATA_PORT];
    if (!(inSpec instanceof DataTableSpec)) {
        throw new IllegalArgumentException("Invalid input data");
    }
    final DataTableSpec tableSpec = (DataTableSpec) inSpec;
    if (tableSpec.findColumnIndex(classColumn) < 0) {
        throw new InvalidSettingsException("Please define the classification column");
    }
    if (tableSpec.getNumColumns() < 2) {
        throw new InvalidSettingsException("Input table should contain at least 2 columns");
    }
    final int maxNoOfNominalVals = m_maxNoOfNominalVals.getIntValue();
    // check if the table contains at least one nominal column
    // and check each nominal column with a valid domain
    // if it contains more values than allowed
    boolean containsNominalCol = false;
    final List<String> toBigNominalColumns = new ArrayList<>();
    for (int i = 0, length = tableSpec.getNumColumns(); i < length; i++) {
        final DataColumnSpec colSpec = tableSpec.getColumnSpec(i);
        if (colSpec.getType().isCompatible(NominalValue.class)) {
            containsNominalCol = true;
            final DataColumnDomain domain = colSpec.getDomain();
            if (domain != null && domain.getValues() != null) {
                if (domain.getValues().size() > maxNoOfNominalVals) {
                    // unique values
                    if (colSpec.getName().equals(classColumn)) {
                        // contains too many unique values
                        throw new InvalidSettingsException("Class column domain contains too many unique values" + " (" + domain.getValues().size() + ")");
                    }
                    toBigNominalColumns.add(colSpec.getName() + " (" + domain.getValues().size() + ")");
                }
            }
        }
    }
    if (!containsNominalCol) {
        throw new InvalidSettingsException("No possible class attribute found in input table");
    }
    if (toBigNominalColumns.size() == 1) {
        setWarningMessage("Column " + toBigNominalColumns.get(0) + " will possibly be skipped.");
    } else if (toBigNominalColumns.size() > 1) {
        final StringBuilder buf = new StringBuilder();
        buf.append("The following columns will possibly be skipped: ");
        for (int i = 0, length = toBigNominalColumns.size(); i < length; i++) {
            if (i != 0) {
                buf.append(", ");
            }
            if (i > 3) {
                buf.append("...");
                break;
            }
            buf.append(toBigNominalColumns.get(i));
        }
        setWarningMessage(buf.toString());
    }
    if (tableSpec.getNumColumns() - toBigNominalColumns.size() < 1) {
        throw new InvalidSettingsException("Not enough valid columns");
    }
    return new PortObjectSpec[] { new NaiveBayesPortObjectSpec(tableSpec, tableSpec.getColumnSpec(classColumn)) };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ArrayList(java.util.ArrayList) NaiveBayesPortObjectSpec(org.knime.base.node.mine.bayes.naivebayes.port.NaiveBayesPortObjectSpec) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnDomain(org.knime.core.data.DataColumnDomain) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NaiveBayesPortObjectSpec(org.knime.base.node.mine.bayes.naivebayes.port.NaiveBayesPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec)

Example 10 with PortObjectSpec

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

the class DecTreePredictorNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
public PortObject[] execute(final PortObject[] inPorts, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    exec.setMessage("Decision Tree Predictor: Loading predictor...");
    PMMLPortObject port = (PMMLPortObject) inPorts[INMODELPORT];
    List<Node> models = port.getPMMLValue().getModels(PMMLModelType.TreeModel);
    if (models.isEmpty()) {
        String msg = "Decision Tree evaluation failed: " + "No tree model found.";
        LOGGER.error(msg);
        throw new RuntimeException(msg);
    }
    PMMLDecisionTreeTranslator trans = new PMMLDecisionTreeTranslator();
    port.initializeModelTranslator(trans);
    DecisionTree decTree = trans.getDecisionTree();
    decTree.resetColorInformation();
    BufferedDataTable inData = (BufferedDataTable) inPorts[INDATAPORT];
    // get column with color information
    String colorColumn = null;
    for (DataColumnSpec s : inData.getDataTableSpec()) {
        if (s.getColorHandler() != null) {
            colorColumn = s.getName();
            break;
        }
    }
    decTree.setColorColumn(colorColumn);
    exec.setMessage("Decision Tree Predictor: start execution.");
    PortObjectSpec[] inSpecs = new PortObjectSpec[] { inPorts[0].getSpec(), inPorts[1].getSpec() };
    DataTableSpec outSpec = createOutTableSpec(inSpecs);
    BufferedDataContainer outData = exec.createDataContainer(outSpec);
    long coveredPattern = 0;
    long nrPattern = 0;
    long rowCount = 0;
    long numberRows = inData.size();
    exec.setMessage("Classifying...");
    for (DataRow thisRow : inData) {
        DataCell cl = null;
        LinkedHashMap<String, Double> classDistrib = null;
        try {
            Pair<DataCell, LinkedHashMap<DataCell, Double>> pair = decTree.getWinnerAndClasscounts(thisRow, inData.getDataTableSpec());
            cl = pair.getFirst();
            LinkedHashMap<DataCell, Double> classCounts = pair.getSecond();
            classDistrib = getDistribution(classCounts);
            if (coveredPattern < m_maxNumCoveredPattern.getIntValue()) {
                // remember this one for HiLite support
                decTree.addCoveredPattern(thisRow, inData.getDataTableSpec());
                coveredPattern++;
            } else {
                // too many patterns for HiLite - at least remember color
                decTree.addCoveredColor(thisRow, inData.getDataTableSpec());
            }
            nrPattern++;
        } catch (Exception e) {
            LOGGER.error("Decision Tree evaluation failed: " + e.getMessage());
            throw e;
        }
        if (cl == null) {
            LOGGER.error("Decision Tree evaluation failed: result empty");
            throw new Exception("Decision Tree evaluation failed.");
        }
        DataCell[] newCells = new DataCell[outSpec.getNumColumns()];
        int numInCells = thisRow.getNumCells();
        for (int i = 0; i < numInCells; i++) {
            newCells[i] = thisRow.getCell(i);
        }
        if (m_showDistribution.getBooleanValue()) {
            for (int i = numInCells; i < newCells.length - 1; i++) {
                String predClass = outSpec.getColumnSpec(i).getName();
                if (classDistrib != null && classDistrib.get(predClass) != null) {
                    newCells[i] = new DoubleCell(classDistrib.get(predClass));
                } else {
                    newCells[i] = new DoubleCell(0.0);
                }
            }
        }
        newCells[newCells.length - 1] = cl;
        outData.addRowToTable(new DefaultRow(thisRow.getKey(), newCells));
        rowCount++;
        if (rowCount % 100 == 0) {
            exec.setProgress(rowCount / (double) numberRows, "Classifying... Row " + rowCount + " of " + numberRows);
        }
        exec.checkCanceled();
    }
    if (coveredPattern < nrPattern) {
        // let the user know that we did not store all available pattern
        // for HiLiting.
        this.setWarningMessage("Tree only stored first " + m_maxNumCoveredPattern.getIntValue() + " (of " + nrPattern + ") rows for HiLiting!");
    }
    outData.close();
    m_decTree = decTree;
    exec.setMessage("Decision Tree Predictor: end execution.");
    return new BufferedDataTable[] { outData.getTable() };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLDecisionTreeTranslator(org.knime.base.node.mine.decisiontree2.PMMLDecisionTreeTranslator) DoubleCell(org.knime.core.data.def.DoubleCell) Node(org.w3c.dom.Node) DataRow(org.knime.core.data.DataRow) LinkedHashMap(java.util.LinkedHashMap) DataColumnSpec(org.knime.core.data.DataColumnSpec) BufferedDataTable(org.knime.core.node.BufferedDataTable) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) DecisionTree(org.knime.base.node.mine.decisiontree2.model.DecisionTree) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IOException(java.io.IOException) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) DataCell(org.knime.core.data.DataCell) DefaultRow(org.knime.core.data.def.DefaultRow)

Aggregations

PortObjectSpec (org.knime.core.node.port.PortObjectSpec)123 DataTableSpec (org.knime.core.data.DataTableSpec)91 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)81 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)35 DataColumnSpec (org.knime.core.data.DataColumnSpec)28 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)28 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)24 FlowVariablePortObjectSpec (org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec)19 InactiveBranchPortObjectSpec (org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec)18 IOException (java.io.IOException)17 PortObject (org.knime.core.node.port.PortObject)14 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)14 DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)12 DatabaseQueryConnectionSettings (org.knime.core.node.port.database.DatabaseQueryConnectionSettings)12 InactiveBranchPortObject (org.knime.core.node.port.inactive.InactiveBranchPortObject)12 DataType (org.knime.core.data.DataType)11 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)11 File (java.io.File)10 ArrayList (java.util.ArrayList)10 DoubleValue (org.knime.core.data.DoubleValue)10