Search in sources :

Example 11 with RegressionTreeModelPortObjectSpec

use of org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec in project knime-core by knime.

the class RegressionTreePredictorNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
    RegressionTreeModelPortObject model = (RegressionTreeModelPortObject) inObjects[0];
    RegressionTreeModelPortObjectSpec modelSpec = model.getSpec();
    BufferedDataTable data = (BufferedDataTable) inObjects[1];
    DataTableSpec dataSpec = data.getDataTableSpec();
    final RegressionTreePredictor pred = new RegressionTreePredictor(model.getModel(), modelSpec, dataSpec, m_configuration);
    ColumnRearranger rearranger = pred.getPredictionRearranger();
    BufferedDataTable outTable = exec.createColumnRearrangeTable(data, rearranger, exec);
    return new BufferedDataTable[] { outTable };
}
Also used : RegressionTreeModelPortObject(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObject) DataTableSpec(org.knime.core.data.DataTableSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) BufferedDataTable(org.knime.core.node.BufferedDataTable) RegressionTreeModelPortObjectSpec(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec)

Example 12 with RegressionTreeModelPortObjectSpec

use of org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec in project knime-core by knime.

the class RegressionTreePredictorNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    RegressionTreeModelPortObjectSpec modelSpec = (RegressionTreeModelPortObjectSpec) inSpecs[0];
    String targetColName = modelSpec.getTargetColumn().getName();
    if (m_configuration == null) {
        m_configuration = RegressionTreePredictorConfiguration.createDefault(targetColName);
    } else if (!m_configuration.isChangePredictionColumnName()) {
        m_configuration.setPredictionColumnName(RegressionTreePredictorConfiguration.getPredictColumnName(targetColName));
    }
    DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
    final RegressionTreePredictor pred = new RegressionTreePredictor(null, modelSpec, dataSpec, m_configuration);
    ColumnRearranger rearranger = pred.getPredictionRearranger();
    // rearranger may be null if confidence values are appended but the
    // model does not have a list of possible target values
    DataTableSpec outSpec = rearranger != null ? rearranger.createSpec() : null;
    return new DataTableSpec[] { outSpec };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) RegressionTreeModelPortObjectSpec(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec)

Aggregations

RegressionTreeModelPortObjectSpec (org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec)12 DataTableSpec (org.knime.core.data.DataTableSpec)9 RegressionTreeModel (org.knime.base.node.mine.treeensemble2.model.RegressionTreeModel)5 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)5 RegressionTreeModelPortObject (org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObject)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)3 BufferedDataTable (org.knime.core.node.BufferedDataTable)3 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)3 TreeModelRegression (org.knime.base.node.mine.treeensemble2.model.TreeModelRegression)2 RegressionTreeModelPMMLTranslator (org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator)2 FilterLearnColumnRearranger (org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.FilterLearnColumnRearranger)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 PortObject (org.knime.core.node.port.PortObject)2 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)2 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)2 ArrayList (java.util.ArrayList)1 RandomData (org.apache.commons.math.random.RandomData)1 TreeData (org.knime.base.node.mine.treeensemble2.data.TreeData)1 TreeDataCreator (org.knime.base.node.mine.treeensemble2.data.TreeDataCreator)1 BitVectorDataIndexManager (org.knime.base.node.mine.treeensemble2.data.memberships.BitVectorDataIndexManager)1