Search in sources :

Example 1 with RowSample

use of org.knime.base.node.mine.treeensemble.sample.row.RowSample in project knime-core by knime.

the class TreeLearnerClassification method learnSingleTree.

/**
 * {@inheritDoc}
 */
@Override
public TreeModelClassification learnSingleTree(final ExecutionMonitor exec, final RandomData rd) throws CanceledExecutionException {
    final TreeData data = getData();
    final RowSample rowSampling = getRowSampling();
    final TreeEnsembleLearnerConfiguration config = getConfig();
    final TreeTargetNominalColumnData targetColumn = (TreeTargetNominalColumnData) data.getTargetColumn();
    double[] dataMemberships = new double[data.getNrRows()];
    for (int i = 0; i < dataMemberships.length; i++) {
        // dataMemberships[i] = m_rowSampling.getCountFor(i) > 0 ? 1.0 : 0.0;
        dataMemberships[i] = rowSampling.getCountFor(i);
    }
    ClassificationPriors targetPriors = targetColumn.getDistribution(dataMemberships, config);
    BitSet forbiddenColumnSet = new BitSet(data.getNrAttributes());
    // TreeNodeMembershipController rootMembershipController = new TreeNodeMembershipController(data, dataMemberships);
    TreeNodeMembershipController rootMembershipController = null;
    TreeNodeClassification rootNode = buildTreeNode(exec, 0, dataMemberships, TreeNodeSignature.ROOT_SIGNATURE, targetPriors, forbiddenColumnSet, rootMembershipController);
    assert forbiddenColumnSet.cardinality() == 0;
    rootNode.setTreeNodeCondition(TreeNodeTrueCondition.INSTANCE);
    return new TreeModelClassification(rootNode);
}
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) BitSet(java.util.BitSet) TreeData(org.knime.base.node.mine.treeensemble.data.TreeData) RowSample(org.knime.base.node.mine.treeensemble.sample.row.RowSample) TreeTargetNominalColumnData(org.knime.base.node.mine.treeensemble.data.TreeTargetNominalColumnData) ClassificationPriors(org.knime.base.node.mine.treeensemble.data.ClassificationPriors) TreeModelClassification(org.knime.base.node.mine.treeensemble.model.TreeModelClassification)

Example 2 with RowSample

use of org.knime.base.node.mine.treeensemble.sample.row.RowSample in project knime-core by knime.

the class TreeLearnerRegression method learnSingleTree.

/**
 * {@inheritDoc}
 */
@Override
public TreeModelRegression learnSingleTree(final ExecutionMonitor exec, final RandomData rd) throws CanceledExecutionException {
    final TreeTargetNumericColumnData targetColumn = getTargetData();
    final TreeData data = getData();
    final RowSample rowSampling = getRowSampling();
    final TreeEnsembleLearnerConfiguration config = getConfig();
    double[] dataMemberships = new double[data.getNrRows()];
    for (int i = 0; i < dataMemberships.length; i++) {
        dataMemberships[i] = rowSampling.getCountFor(i);
    }
    RegressionPriors targetPriors = targetColumn.getPriors(dataMemberships, config);
    BitSet forbiddenColumnSet = new BitSet(data.getNrAttributes());
    // TreeNodeMembershipController rootMembershipController = new TreeNodeMembershipController(data, dataMemberships);
    TreeNodeMembershipController rootMembershipController = null;
    TreeNodeRegression rootNode = buildTreeNode(exec, 0, dataMemberships, TreeNodeSignature.ROOT_SIGNATURE, targetPriors, forbiddenColumnSet, rootMembershipController);
    assert forbiddenColumnSet.cardinality() == 0;
    rootNode.setTreeNodeCondition(TreeNodeTrueCondition.INSTANCE);
    return new TreeModelRegression(rootNode);
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration) TreeNodeMembershipController(org.knime.base.node.mine.treeensemble.data.TreeNodeMembershipController) RegressionPriors(org.knime.base.node.mine.treeensemble.data.RegressionPriors) BitSet(java.util.BitSet) TreeTargetNumericColumnData(org.knime.base.node.mine.treeensemble.data.TreeTargetNumericColumnData) TreeData(org.knime.base.node.mine.treeensemble.data.TreeData) RowSample(org.knime.base.node.mine.treeensemble.sample.row.RowSample) TreeNodeRegression(org.knime.base.node.mine.treeensemble.model.TreeNodeRegression) TreeModelRegression(org.knime.base.node.mine.treeensemble.model.TreeModelRegression)

Aggregations

BitSet (java.util.BitSet)2 TreeData (org.knime.base.node.mine.treeensemble.data.TreeData)2 TreeNodeMembershipController (org.knime.base.node.mine.treeensemble.data.TreeNodeMembershipController)2 TreeEnsembleLearnerConfiguration (org.knime.base.node.mine.treeensemble.node.learner.TreeEnsembleLearnerConfiguration)2 RowSample (org.knime.base.node.mine.treeensemble.sample.row.RowSample)2 ClassificationPriors (org.knime.base.node.mine.treeensemble.data.ClassificationPriors)1 RegressionPriors (org.knime.base.node.mine.treeensemble.data.RegressionPriors)1 TreeTargetNominalColumnData (org.knime.base.node.mine.treeensemble.data.TreeTargetNominalColumnData)1 TreeTargetNumericColumnData (org.knime.base.node.mine.treeensemble.data.TreeTargetNumericColumnData)1 TreeModelClassification (org.knime.base.node.mine.treeensemble.model.TreeModelClassification)1 TreeModelRegression (org.knime.base.node.mine.treeensemble.model.TreeModelRegression)1 TreeNodeClassification (org.knime.base.node.mine.treeensemble.model.TreeNodeClassification)1 TreeNodeRegression (org.knime.base.node.mine.treeensemble.model.TreeNodeRegression)1