use of org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition in project knime-core by knime.
the class LiteralConditionParser method handleSimplePredicate.
private TreeNodeColumnCondition handleSimplePredicate(final SimplePredicate simplePred, final boolean acceptsMissings) {
String field = simplePred.getField();
if (m_metaDataMapper.isNominal(field)) {
NominalAttributeColumnHelper colHelper = m_metaDataMapper.getNominalColumnHelper(field);
return new TreeNodeNominalCondition(colHelper.getMetaData(), colHelper.getRepresentation(simplePred.getValue()).getAssignedInteger(), acceptsMissings);
} else {
TreeNumericColumnMetaData metaData = m_metaDataMapper.getNumericColumnHelper(field).getMetaData();
double value = Double.parseDouble(simplePred.getValue());
return new TreeNodeNumericCondition(metaData, value, parseNumericOperator(simplePred.getOperator()), acceptsMissings);
}
}
use of org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition in project knime-core by knime.
the class LiteralConditionParser method parseSurrogateCompound.
private AbstractTreeNodeSurrogateCondition parseSurrogateCompound(final CompoundPredicate compound) {
// PMML requires us to realize surrogates as a chain of compound condition because it doesn't enforce an order
// among the predicates in the surrogate condition
List<TreeNodeColumnCondition> conds = new ArrayList<>();
boolean defaultResponse = unpackSurrogateChainIntoList(compound, conds);
CheckUtils.checkArgument(!conds.isEmpty(), "The surrogate conditon '%s' contains no column conditions.", compound);
return conds.size() > 1 ? new TreeNodeSurrogateCondition(conds.toArray(new TreeNodeColumnCondition[conds.size()]), defaultResponse) : new TreeNodeSurrogateOnlyDefDirCondition(conds.get(0), defaultResponse);
}
use of org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition in project knime-core by knime.
the class ConditionExporter method exportCondition.
void exportCondition(final TreeNodeCondition condition, final Node pmmlNode) {
if (condition instanceof TreeNodeTrueCondition) {
pmmlNode.addNewTrue();
} else if (condition instanceof TreeNodeColumnCondition) {
final TreeNodeColumnCondition colCondition = (TreeNodeColumnCondition) condition;
exportColumnCondition(colCondition, pmmlNode);
} else if (condition instanceof AbstractTreeNodeSurrogateCondition) {
final AbstractTreeNodeSurrogateCondition surrogateCond = (AbstractTreeNodeSurrogateCondition) condition;
setValuesFromPMMLCompoundPredicate(pmmlNode.addNewCompoundPredicate(), surrogateCond.toPMMLPredicate());
} else {
throw new IllegalStateException("Unsupported condition (not implemented): " + condition.getClass().getSimpleName());
}
}
Aggregations