def _nyoka_rule(self, simple_rule: models.SimpleRule) -> nyoka_pmml.SimpleRule: return nyoka_pmml.SimpleRule( SimplePredicate=None if (simple_rule.predicate is None or not isinstance(simple_rule.predicate, models.SimplePredicate)) else nyoka_pmml.SimplePredicate( field=simple_rule.predicate.field, operator=simple_rule.predicate.operator.name, value=simple_rule.predicate.value), CompoundPredicate=None if (simple_rule.predicate is None or not isinstance(simple_rule.predicate, models.CompoundPredicate)) else nyoka_pmml.CompoundPredicate( booleanOperator=simple_rule.predicate.booleanOperator.name, SimplePredicate=[ nyoka_pmml.SimplePredicate(field=sp.field, operator=sp.operator.name, value=sp.value) for sp in simple_rule.predicate.simplePredicates ]), score=simple_rule.score, id=simple_rule.id, recordCount=simple_rule.recordCount, nbCorrect=simple_rule.nbCorrect, confidence=simple_rule.confidence, weight=simple_rule.weight)
def create_right_node(obj, derived_col_names): nd = pml.Node() nd.set_SimplePredicate( pml.SimplePredicate( field=derived_col_names[int(obj['split_feature'])], operator=SIMPLE_PREDICATE_OPERATOR.GREATER_THAN, value="{:.16f}".format(obj['threshold']))) create_node(obj['right_child'], nd, derived_col_names) return nd