Search in sources :

Example 1 with PMMLObject

use of org.dmg.pmml.PMMLObject in project jpmml-sparkml by jpmml.

the class TreeModelCompactor method getParentNode.

private Node getParentNode() {
    Deque<PMMLObject> parents = getParents();
    PMMLObject parent = parents.peekFirst();
    if (parent instanceof Node) {
        return (Node) parent;
    }
    return null;
}
Also used : Node(org.dmg.pmml.tree.Node) PMMLObject(org.dmg.pmml.PMMLObject)

Example 2 with PMMLObject

use of org.dmg.pmml.PMMLObject in project jpmml-sparkml by jpmml.

the class TreeModelCompactor method isCategoricalField.

private boolean isCategoricalField(FieldName name) {
    Deque<PMMLObject> parents = getParents();
    for (PMMLObject parent : parents) {
        if (parent instanceof Node) {
            Node node = (Node) parent;
            Predicate predicate = node.getPredicate();
            if (predicate instanceof SimpleSetPredicate) {
                SimpleSetPredicate simpleSetPredicate = (SimpleSetPredicate) predicate;
                FieldName categoricalField = simpleSetPredicate.getField();
                if ((name).equals(categoricalField)) {
                    return true;
                }
            } else if (predicate instanceof True) {
                True truePredicate = (True) predicate;
                FieldName categoricalField = this.categoricalFields.get(truePredicate);
                if ((name).equals(categoricalField)) {
                    return true;
                }
            }
        } else {
            return false;
        }
    }
    return false;
}
Also used : Node(org.dmg.pmml.tree.Node) PMMLObject(org.dmg.pmml.PMMLObject) True(org.dmg.pmml.True) FieldName(org.dmg.pmml.FieldName) Predicate(org.dmg.pmml.Predicate) SimplePredicate(org.dmg.pmml.SimplePredicate) SimpleSetPredicate(org.dmg.pmml.SimpleSetPredicate) SimpleSetPredicate(org.dmg.pmml.SimpleSetPredicate)

Aggregations

PMMLObject (org.dmg.pmml.PMMLObject)2 Node (org.dmg.pmml.tree.Node)2 FieldName (org.dmg.pmml.FieldName)1 Predicate (org.dmg.pmml.Predicate)1 SimplePredicate (org.dmg.pmml.SimplePredicate)1 SimpleSetPredicate (org.dmg.pmml.SimpleSetPredicate)1 True (org.dmg.pmml.True)1