Search in sources :

Example 1 with TreeNodeNumericCondition

use of org.knime.base.node.mine.treeensemble.model.TreeNodeNumericCondition in project knime-core by knime.

the class TreeNumericColumnData method updateChildMemberships.

@Override
public void updateChildMemberships(final TreeNodeCondition childCondition, final double[] parentMemberships, final double[] childMembershipsToUpdate) {
    final TreeNodeNumericCondition numCondition = (TreeNodeNumericCondition) childCondition;
    final NumericOperator numOperator = numCondition.getNumericOperator();
    final double splitValue = numCondition.getSplitValue();
    for (int i = 0; i < m_originalIndexInColumnList.length; i++) {
        final double value = getSorted(i);
        final int originalColIndex = m_originalIndexInColumnList[i];
        boolean matches;
        switch(numOperator) {
            case LessThanOrEqual:
                matches = value <= splitValue;
                break;
            case LargerThan:
                matches = value > splitValue;
                break;
            default:
                throw new IllegalStateException("Unknown operator " + numOperator);
        }
        if (!matches) {
            childMembershipsToUpdate[originalColIndex] = 0.0;
        } else {
            assert childMembershipsToUpdate[originalColIndex] == parentMemberships[originalColIndex];
        }
    }
}
Also used : TreeNodeNumericCondition(org.knime.base.node.mine.treeensemble.model.TreeNodeNumericCondition) NumericOperator(org.knime.base.node.mine.treeensemble.model.TreeNodeNumericCondition.NumericOperator)

Aggregations

TreeNodeNumericCondition (org.knime.base.node.mine.treeensemble.model.TreeNodeNumericCondition)1 NumericOperator (org.knime.base.node.mine.treeensemble.model.TreeNodeNumericCondition.NumericOperator)1