Search in sources :

Example 11 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RandomForestRegressionLearnerNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    final DataTableSpec inSpec = specs[0];
    TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(true);
    cfg.loadInDialog(settings, inSpec);
    m_optionsPanel.loadSettingsFrom(inSpec, cfg);
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration) DataTableSpec(org.knime.core.data.DataTableSpec)

Example 12 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RegressionTreeLearnerNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(true);
    m_optionsPanel.saveSettings(cfg);
    cfg.save(settings);
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration)

Example 13 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RegressionTreeLearnerNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    final DataTableSpec inSpec = specs[0];
    TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(true);
    cfg.loadInDialog(settings, inSpec);
    m_optionsPanel.loadSettingsFrom(inSpec, cfg);
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration) DataTableSpec(org.knime.core.data.DataTableSpec)

Example 14 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RegressionTreeLearnerNodeModel method loadValidatedSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
    TreeEnsembleLearnerConfiguration config = new TreeEnsembleLearnerConfiguration(true);
    config.loadInModel(settings);
    m_configuration = config;
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration)

Example 15 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class TreeLearnerClassification method buildTreeNode.

private TreeNodeClassification buildTreeNode(final ExecutionMonitor exec, final int currentDepth, final double[] rowSampleWeights, final TreeNodeSignature treeNodeSignature, final ClassificationPriors targetPriors, final BitSet forbiddenColumnSet, final TreeNodeMembershipController membershipController) throws CanceledExecutionException {
    final TreeData data = getData();
    final TreeEnsembleLearnerConfiguration config = getConfig();
    exec.checkCanceled();
    SplitCandidate bestSplit = findBestSplitClassification(currentDepth, rowSampleWeights, treeNodeSignature, targetPriors, forbiddenColumnSet, membershipController);
    if (bestSplit == null) {
        return new TreeNodeClassification(treeNodeSignature, targetPriors, getConfig());
    }
    TreeAttributeColumnData splitColumn = bestSplit.getColumnData();
    final int attributeIndex = splitColumn.getMetaData().getAttributeIndex();
    boolean markAttributeAsForbidden = !bestSplit.canColumnBeSplitFurther();
    forbiddenColumnSet.set(attributeIndex, markAttributeAsForbidden);
    TreeNodeCondition[] childConditions = bestSplit.getChildConditions();
    if (childConditions.length > Short.MAX_VALUE) {
        throw new RuntimeException("Too many children when splitting " + "attribute " + bestSplit.getColumnData() + " (maximum supported: " + Short.MAX_VALUE + "): " + childConditions.length);
    }
    TreeNodeClassification[] childNodes = new TreeNodeClassification[childConditions.length];
    final double[] dataMemberships = rowSampleWeights;
    // final double[] dataMemberships = rowSampleWeights.getMemberships();
    final double[] childMemberships = new double[dataMemberships.length];
    final TreeTargetNominalColumnData targetColumn = (TreeTargetNominalColumnData) data.getTargetColumn();
    for (int i = 0; i < childConditions.length; i++) {
        System.arraycopy(dataMemberships, 0, childMemberships, 0, dataMemberships.length);
        TreeNodeCondition cond = childConditions[i];
        splitColumn.updateChildMemberships(cond, dataMemberships, childMemberships);
        // TreeNodeMembershipController childMembershipController = membershipController.createChildTreeNodeMembershipController(childMemberships);
        TreeNodeMembershipController childMembershipController = null;
        ClassificationPriors childTargetPriors = targetColumn.getDistribution(childMemberships, config);
        TreeNodeSignature childSignature = treeNodeSignature.createChildSignature((short) i);
        childNodes[i] = buildTreeNode(exec, currentDepth + 1, childMemberships, childSignature, childTargetPriors, forbiddenColumnSet, childMembershipController);
        childNodes[i].setTreeNodeCondition(cond);
    }
    if (markAttributeAsForbidden) {
        forbiddenColumnSet.set(attributeIndex, false);
    }
    return new TreeNodeClassification(treeNodeSignature, targetPriors, childNodes, getConfig());
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration) TreeNodeClassification(org.knime.base.node.mine.treeensemble.model.TreeNodeClassification) TreeNodeMembershipController(org.knime.base.node.mine.treeensemble.data.TreeNodeMembershipController) TreeAttributeColumnData(org.knime.base.node.mine.treeensemble.data.TreeAttributeColumnData) TreeNodeSignature(org.knime.base.node.mine.treeensemble.model.TreeNodeSignature) TreeData(org.knime.base.node.mine.treeensemble.data.TreeData) TreeNodeCondition(org.knime.base.node.mine.treeensemble.model.TreeNodeCondition) TreeTargetNominalColumnData(org.knime.base.node.mine.treeensemble.data.TreeTargetNominalColumnData) ClassificationPriors(org.knime.base.node.mine.treeensemble.data.ClassificationPriors)

Aggregations

TreeEnsembleLearnerConfiguration (org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration)22 TreeData (org.knime.base.node.mine.treeensemble.data.TreeData)6 DataTableSpec (org.knime.core.data.DataTableSpec)5 TreeAttributeColumnData (org.knime.base.node.mine.treeensemble.data.TreeAttributeColumnData)4 TreeNodeMembershipController (org.knime.base.node.mine.treeensemble.data.TreeNodeMembershipController)4 TreeTargetNominalColumnData (org.knime.base.node.mine.treeensemble.data.TreeTargetNominalColumnData)3 TreeTargetNumericColumnData (org.knime.base.node.mine.treeensemble.data.TreeTargetNumericColumnData)3 BitSet (java.util.BitSet)2 ClassificationPriors (org.knime.base.node.mine.treeensemble.data.ClassificationPriors)2 RegressionPriors (org.knime.base.node.mine.treeensemble.data.RegressionPriors)2 TreeNodeClassification (org.knime.base.node.mine.treeensemble.model.TreeNodeClassification)2 TreeNodeCondition (org.knime.base.node.mine.treeensemble.model.TreeNodeCondition)2 TreeNodeRegression (org.knime.base.node.mine.treeensemble.model.TreeNodeRegression)2 TreeNodeSignature (org.knime.base.node.mine.treeensemble.model.TreeNodeSignature)2 ColumnSample (org.knime.base.node.mine.treeensemble.sample.column.ColumnSample)2 ColumnSampleStrategy (org.knime.base.node.mine.treeensemble.sample.column.ColumnSampleStrategy)2 RowSample (org.knime.base.node.mine.treeensemble.sample.row.RowSample)2 AbstractTreeModel (org.knime.base.node.mine.treeensemble.model.AbstractTreeModel)1 TreeEnsembleModel (org.knime.base.node.mine.treeensemble.model.TreeEnsembleModel)1 TreeModelClassification (org.knime.base.node.mine.treeensemble.model.TreeModelClassification)1