Пример #1
0
    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
Пример #2
0
 def subgraph(self, root, inplace=False):
     if inplace:
         graph = self
     else:
         graph = self.copy()
     graph.df = BiGraphDF.subgraph(graph.df, root)
     return graph
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 def remove_redundant(self):
     self.df = BiGraphDF.remove_redundant(self.df)
     return self
Пример #6
0
 def reindex_graph(self):
     self.df = BiGraphDF.reindex_dataframe(self.df)
     return self
Пример #7
0
 def get_row_list(self):
     return BiGraphDF.get_row_list(self.df)
Пример #8
0
 def replace_score(self, new_data, replace_omitted_with_none=False):
     return BiGraphDF.replace_score(self.df, new_data,
                                    replace_omitted_with_none)
Пример #9
0
 def update_score(self, data_dict):
     return BiGraphDF.update_score(self.df, data_dict)
Пример #10
0
 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)
Пример #11
0
 def update_data(self, data_dict, reindex=False):
     return BiGraphDF.update_data(self.df, data_dict, reindex)
Пример #12
0
 def get_score(self,
               keys=None,
               default=None,
               order_dict=False,
               missing='ignore'):
     return BiGraphDF.get_score(self.df, keys, default, order_dict, missing)
Пример #13
0
 def has_split(self, node=None):
     return BiGraphDF.has_split(self.df, node)
Пример #14
0
 def leaf_node(self, node=None):
     return BiGraphDF.leaf_node(self.df, node)
Пример #15
0
 def n_child(self, node=None):
     return BiGraphDF.n_child(self.df, node)
Пример #16
0
 def n_nodes(self):
     return BiGraphDF.n_nodes(self.df)