Search in sources :

Example 21 with TreeEnsemblePredictor

use of org.knime.base.node.mine.treeensemble.node.predictor.TreeEnsemblePredictor in project knime-core by knime.

the class TreeEnsembleClassificationPredictorNodeModel 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 {
            TreeEnsembleModelPortObject model = (TreeEnsembleModelPortObject) ((PortObjectInput) inputs[0]).getPortObject();
            TreeEnsembleModelPortObjectSpec modelSpec = model.getSpec();
            DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
            final TreeEnsemblePredictor pred = new TreeEnsemblePredictor(modelSpec, model, dataSpec, m_configuration);
            ColumnRearranger rearranger = pred.getPredictionRearranger();
            StreamableFunction func = rearranger.createStreamableFunction(1, 0);
            func.runFinal(inputs, outputs, exec);
        }
    };
}
Also used : TreeEnsembleModelPortObject(org.knime.base.node.mine.treeensemble.model.TreeEnsembleModelPortObject) DataTableSpec(org.knime.core.data.DataTableSpec) ExecutionContext(org.knime.core.node.ExecutionContext) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) TreeEnsembleModelPortObjectSpec(org.knime.base.node.mine.treeensemble.model.TreeEnsembleModelPortObjectSpec) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) TreeEnsemblePredictor(org.knime.base.node.mine.treeensemble.node.predictor.TreeEnsemblePredictor) StreamableFunction(org.knime.core.node.streamable.StreamableFunction)

Example 22 with TreeEnsemblePredictor

use of org.knime.base.node.mine.treeensemble.node.predictor.TreeEnsemblePredictor in project knime-core by knime.

the class TreeEnsembleClassificationPredictorNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    TreeEnsembleModelPortObjectSpec modelSpec = (TreeEnsembleModelPortObjectSpec) inSpecs[0];
    String targetColName = modelSpec.getTargetColumn().getName();
    if (m_configuration == null) {
        m_configuration = TreeEnsemblePredictorConfiguration.createDefault(false, targetColName);
    } else if (!m_configuration.isChangePredictionColumnName()) {
        m_configuration.setPredictionColumnName(TreeEnsemblePredictorConfiguration.getPredictColumnName(targetColName));
    }
    modelSpec.assertTargetTypeMatches(false);
    DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
    final TreeEnsemblePredictor pred = new TreeEnsemblePredictor(modelSpec, null, 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) TreeEnsembleModelPortObjectSpec(org.knime.base.node.mine.treeensemble.model.TreeEnsembleModelPortObjectSpec) TreeEnsemblePredictor(org.knime.base.node.mine.treeensemble.node.predictor.TreeEnsemblePredictor)

Aggregations

TreeEnsemblePredictor (org.knime.base.node.mine.treeensemble.node.predictor.TreeEnsemblePredictor)22 TreeEnsembleModelPortObjectSpec (org.knime.base.node.mine.treeensemble.model.TreeEnsembleModelPortObjectSpec)18 DataTableSpec (org.knime.core.data.DataTableSpec)18 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)18 TreeEnsembleModelPortObject (org.knime.base.node.mine.treeensemble.model.TreeEnsembleModelPortObject)10 FilterLearnColumnRearranger (org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration.FilterLearnColumnRearranger)8 BufferedDataTable (org.knime.core.node.BufferedDataTable)8 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)8 IOException (java.io.IOException)4 ExecutionException (java.util.concurrent.ExecutionException)4 TreeData (org.knime.base.node.mine.treeensemble.data.TreeData)4 TreeDataCreator (org.knime.base.node.mine.treeensemble.data.TreeDataCreator)4 TreeEnsembleLearner (org.knime.base.node.mine.treeensemble.learner.TreeEnsembleLearner)4 TreeEnsembleModel (org.knime.base.node.mine.treeensemble.model.TreeEnsembleModel)4 TreeEnsemblePredictorConfiguration (org.knime.base.node.mine.treeensemble.node.predictor.TreeEnsemblePredictorConfiguration)4 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)4 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)4 PortObject (org.knime.core.node.port.PortObject)4 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)4 DataCell (org.knime.core.data.DataCell)2