use of org.knime.base.node.mine.treeensemble2.model.TreeNodeNumericCondition.NumericOperator in project knime-core by knime.
the class TreeNumericColumnData method updateChildMemberships.
@Override
public BitSet updateChildMemberships(final TreeNodeCondition childCondition, final DataMemberships parentMemberships) {
final TreeNodeNumericCondition numCondition = (TreeNodeNumericCondition) childCondition;
final NumericOperator numOperator = numCondition.getNumericOperator();
final double splitValue = numCondition.getSplitValue();
final ColumnMemberships columnMemberships = parentMemberships.getColumnMemberships(getMetaData().getAttributeIndex());
columnMemberships.reset();
final BitSet inChild = new BitSet(columnMemberships.size());
int startIndex = 0;
// }
if (!columnMemberships.nextIndexFrom(startIndex)) {
throw new IllegalStateException("The current columnMemberships object contains no element that satisfies the splitcondition");
}
final int lengthNonMissing = getLengthNonMissing();
do {
final double value = getSorted(columnMemberships.getIndexInColumn());
boolean matches;
switch(numOperator) {
case LessThanOrEqual:
matches = value <= splitValue;
break;
case LargerThan:
matches = value > splitValue;
break;
case LessThanOrEqualOrMissing:
matches = Double.isNaN(value) ? true : value <= splitValue;
break;
case LargerThanOrMissing:
matches = Double.isNaN(value) ? true : value > splitValue;
break;
default:
throw new IllegalStateException("Unknown operator " + numOperator);
}
if (matches) {
inChild.set(columnMemberships.getIndexInDataMemberships());
}
} while (columnMemberships.next() && columnMemberships.getIndexInColumn() < lengthNonMissing);
// reached end of columnMemberships
if (columnMemberships.getIndexInColumn() < lengthNonMissing) {
return inChild;
}
// handle missing values
if (numOperator.equals(NumericOperator.LessThanOrEqualOrMissing) || numOperator.equals(NumericOperator.LargerThanOrMissing) || numCondition.acceptsMissings()) {
do {
inChild.set(columnMemberships.getIndexInDataMemberships());
} while (columnMemberships.next());
}
return inChild;
}
Aggregations