Tree Structure
Extract main parameters of tree ensemble from config. |
|
Extract ids of children nodes from table of xgboost model. |
|
Transform variable name in index. |
|
Extract the tree structure. |
|
Extract the variable list of each tree path. |
|
Extract the unique and sorted list of variables from all tree paths. |
|
Extract the variable interactions of order two from all tree paths. |
- treehfd.tree_structure.get_params(config: dict) tuple
Extract main parameters of tree ensemble from config.
- treehfd.tree_structure.extract_child_ids(child_id: str) int
Extract ids of children nodes from table of xgboost model.
- treehfd.tree_structure.transform_variables(name: str) int
Transform variable name in index.
- treehfd.tree_structure.extract_tree_structure(tree_table: DataFrame) tuple
Extract the tree structure.
- Parameters:
tree_table (pd.DataFrame) – Dataframe containing the tree structure, derived from the xgboost method trees_to_dataframe.
- Returns:
- variablesnp.ndarray
array with the variable index for each node split, where -1 indicates terminal leaves.
- child_idsnp.ndarray
array with indices of children nodes, with first row for left nodes and second row for right nodes.
- split_valuesnp.ndarray
array with the list of node splitting values.
- Return type:
tuple
- treehfd.tree_structure.extract_variable_paths(tree_structure: tuple, depth_variable: int) list
Extract the variable list of each tree path.
- Parameters:
tree_structure (tuple) – Tuple containing the splitting variables, children node indices, and splitting node values of the tree.
depth_variable (int) – Variables are selected at the first depth_variable levels of the tree for the components of the decomposition.
- Returns:
List of variable list of each tree path.
- Return type:
List
- treehfd.tree_structure.extract_variables(variable_paths: list[list[int]]) ndarray
Extract the unique and sorted list of variables from all tree paths.
- Parameters:
variable_paths (list) – List of variable list of each tree path.
- Returns:
variable_list – Unique and sorted list of variables of the tree.
- Return type:
list
- treehfd.tree_structure.extract_interactions(variable_paths: list[list[int]]) list
Extract the variable interactions of order two from all tree paths.
- Parameters:
variable_paths (list) – List of variable list of each tree path.
- Returns:
interactions – List of variable index pairs, with a pair for each interaction.
- Return type:
list