Search in sources :

Example 1 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class RuleEngine2PortsNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
    BufferedDataTable data = (BufferedDataTable) inData[DATA_PORT];
    m_rowCount = data.size();
    try {
        Pair<ColumnRearranger, PortObject> rearrangerPair = createColumnRearranger((DataTableSpec) inData[DATA_PORT].getSpec(), new DataTableRowInput((DataTable) inData[RULE_PORT]));
        BufferedDataTable predictedTable = exec.createColumnRearrangeTable(data, rearrangerPair.getFirst(), exec);
        PortObject second = rearrangerPair.getSecond();
        if (m_settings.isPMMLRuleSet()) {
            if (m_settings.isProvideStatistics()) {
                PMMLPortObject po = (PMMLPortObject) rearrangerPair.getSecond();
                PMMLPortObject pmmlPortObject = new PMMLPortObject(m_copy.getSpec(), po);
                // Remove extra model.
                pmmlPortObject.addModelTranslater(new PMMLTranslator() {

                    @Override
                    public void initializeFrom(final PMMLDocument pmmlDoc) {
                    }

                    @Override
                    public SchemaType exportTo(final PMMLDocument pmmlDoc, final PMMLPortObjectSpec spec) {
                        return null;
                    }
                });
                second = pmmlPortObject;
            } else {
                second = m_copy;
            }
        }
        return new PortObject[] { predictedTable, second };
    } finally {
        m_rowCount = -1;
    }
}
Also used : BufferedDataTable(org.knime.core.node.BufferedDataTable) DataTable(org.knime.core.data.DataTable) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput) PMMLDocument(org.dmg.pmml.PMMLDocument) PMMLTranslator(org.knime.core.node.port.pmml.PMMLTranslator) PortObject(org.knime.core.node.port.PortObject) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) SchemaType(org.apache.xmlbeans.SchemaType)

Example 2 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class DataTableSpecView method dispose.

/**
 * {@inheritDoc}
 * @since 3.6
 */
@Override
public void dispose() {
    TableContentModel contentModel = m_specView.getContentModel();
    DataTable dataTable = contentModel.getDataTable();
    contentModel.setDataTable(null);
    if (dataTable instanceof ContainerTable) {
        ((ContainerTable) dataTable).clear();
    }
}
Also used : DataTable(org.knime.core.data.DataTable) TableContentModel(org.knime.core.node.tableview.TableContentModel) ContainerTable(org.knime.core.data.container.ContainerTable)

Example 3 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class RegressionTreeLearnerNodeView method newModel.

private void newModel() {
    assert SwingUtilities.isEventDispatchThread();
    final RegressionTreeLearnerNodeModel nodeModel = getNodeModel();
    RegressionTreeModel model = nodeModel.getRegressionTreeModel();
    DataTable hiliteRowSample = nodeModel.getHiliteRowSample();
    UpdateTreeWorker updateWorker = new UpdateTreeWorker(hiliteRowSample, model);
    UpdateTreeWorker old = m_updateWorkerRef.getAndSet(updateWorker);
    if (old != null) {
        old.cancel(true);
    }
    updateWorker.execute();
}
Also used : DataTable(org.knime.core.data.DataTable) RegressionTreeModel(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModel)

Example 4 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class TreeEnsembleLearnerNodeView2 method newModel.

private void newModel(final int index) {
    assert SwingUtilities.isEventDispatchThread();
    final MODEL nodeModel = getNodeModel();
    TreeEnsembleModel model = nodeModel.getEnsembleModel();
    DataTable hiliteRowSample = nodeModel.getHiliteRowSample();
    UpdateTreeWorker updateWorker = new UpdateTreeWorker(hiliteRowSample, model, index);
    UpdateTreeWorker old = m_updateWorkerRef.getAndSet(updateWorker);
    if (old != null) {
        old.cancel(true);
    }
    updateWorker.execute();
}
Also used : DataTable(org.knime.core.data.DataTable) TreeEnsembleModel(org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModel)

Example 5 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class PolyRegLineScatterPlotter method modelChanged.

/**
 * This method must be called if the model has changed. It updates the
 * plotter to show the new model's values.
 */
public void modelChanged() {
    DataTable data = m_model.getDataArray(0);
    m_viewData = m_model.getViewData();
    if (data != null) {
        final DataTableSpec origSpec = data.getDataTableSpec();
        final MyProperties props = (MyProperties) getProperties();
        DataColumnSpec[] colSpecs = new DataColumnSpec[origSpec.getNumColumns() - 1];
        int i = 0;
        for (DataColumnSpec cs : origSpec) {
            if (!m_viewData.targetColumn.equals(cs.getName())) {
                colSpecs[i++] = cs;
            } else {
                m_yColumnSpec = cs;
                getYAxis().setCoordinate(Coordinate.createCoordinate(cs));
            }
        }
        m_xColumnSpec = colSpecs[0];
        getXAxis().setCoordinate(Coordinate.createCoordinate(colSpecs[0]));
        m_filteredSpec = new DataTableSpec(colSpecs);
        try {
            props.m_xColumn.update(m_filteredSpec, colSpecs[0].getName());
        } catch (NotConfigurableException ex) {
            // cannot happen
            assert false : ex.getMessage();
        }
        reset();
        updatePaintModel();
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTable(org.knime.core.data.DataTable) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Aggregations

DataTable (org.knime.core.data.DataTable)64 BufferedDataTable (org.knime.core.node.BufferedDataTable)33 DataRow (org.knime.core.data.DataRow)20 DataTableSpec (org.knime.core.data.DataTableSpec)19 RowKey (org.knime.core.data.RowKey)14 DataCell (org.knime.core.data.DataCell)12 DataColumnSpec (org.knime.core.data.DataColumnSpec)12 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)11 DefaultTable (org.knime.core.data.def.DefaultTable)10 DefaultRow (org.knime.core.data.def.DefaultRow)8 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)7 DefaultDataArray (org.knime.base.node.util.DefaultDataArray)6 DataType (org.knime.core.data.DataType)6 PortObject (org.knime.core.node.port.PortObject)6 RowIterator (org.knime.core.data.RowIterator)5 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)5 ContainerTable (org.knime.core.data.container.ContainerTable)5 DataContainer (org.knime.core.data.container.DataContainer)5 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)5 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)5