def __init__(self, df=None, graph_info=None, verify=True, reindex=True, copy_df=False, copy_graph=False, copy=None): copy_df = copy_df if copy is None else copy copy_graph = copy_graph if copy is None else copy self._fitted = False self._internally_fitted = False self.objective = None self.n_class = None self.class_name = None self.features_name = None self.score_data = None # self.graph_data = None if df is not None: df = BiGraphDF.apply(df, verify, reindex, copy_df) else: root = dict( zip(GRAPH_COL, [ 0, ROOT_PARENT, TREE_LEAF, TREE_LEAF, TYPE_ROOT, None, None ])) df = pd.DataFrame([root], columns=GRAPH_COL) if graph_info is not None: if copy_graph: graph_info = deepcopy(graph_info) self.update_graph_info(**graph_info) self.df = df
def subgraph(self, root, inplace=False): if inplace: graph = self else: graph = self.copy() graph.df = BiGraphDF.subgraph(graph.df, root) return graph
def convert_to_leaf(self, nodes, inplace=False): graph = self if inplace: graph = self else: graph = self.copy() graph = self.copy() graph.df = BiGraphDF.convert_to_leaf(graph.df, nodes) return graph
def add_child(self, parent_node, left_data=None, right_data=None, left_score=None, right_score=None, reindex=False): self.df = BiGraphDF.add_child(self.df, parent_node, left_data, right_data, left_score, right_score, reindex) return self
def remove_redundant(self): self.df = BiGraphDF.remove_redundant(self.df) return self
def reindex_graph(self): self.df = BiGraphDF.reindex_dataframe(self.df) return self
def get_row_list(self): return BiGraphDF.get_row_list(self.df)
def replace_score(self, new_data, replace_omitted_with_none=False): return BiGraphDF.replace_score(self.df, new_data, replace_omitted_with_none)
def update_score(self, data_dict): return BiGraphDF.update_score(self.df, data_dict)
def replace_data(self, new_data, replace_omitted_with_none=False, reindex=False): return BiGraphDF.replace_data(self.df, new_data, replace_omitted_with_none, reindex)
def update_data(self, data_dict, reindex=False): return BiGraphDF.update_data(self.df, data_dict, reindex)
def get_score(self, keys=None, default=None, order_dict=False, missing='ignore'): return BiGraphDF.get_score(self.df, keys, default, order_dict, missing)
def has_split(self, node=None): return BiGraphDF.has_split(self.df, node)
def leaf_node(self, node=None): return BiGraphDF.leaf_node(self.df, node)
def n_child(self, node=None): return BiGraphDF.n_child(self.df, node)
def n_nodes(self): return BiGraphDF.n_nodes(self.df)