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
def generate_Segments_Equal_To_Estimators(val, derived_col_names, col_names): """ It returns number of Segments equal to the estimator of the model. Parameters ---------- val : List Contains nodes in json format. derived_col_names : List Contains column names after preprocessing. col_names : List Contains list of feature/column names. Returns ------- segments_equal_to_estimators : Returns list of segments equal to number of estimator of the model """ segments_equal_to_estimators = [] for i in range(len(val)): main_node = pml.Node(True_=pml.True_()) mining_field_for_innner_segments = col_names m_flds = [] create_node(val[i], main_node, derived_col_names) for name in mining_field_for_innner_segments: m_flds.append(pml.MiningField(name=name)) segments_equal_to_estimators.append((pml.Segment( id=i + 1, True_=pml.True_(), TreeModel=pml.TreeModel( functionName=MINING_FUNCTION.REGRESSION, modelName="DecisionTreeModel", missingValueStrategy="none", noTrueChildStrategy="returnLastPrediction", splitCharacteristic=TREE_SPLIT_CHARACTERISTIC.MULTI, Node=main_node, MiningSchema=pml.MiningSchema(MiningField=m_flds))))) return segments_equal_to_estimators