Cartesian Partitions
Cartesian tree partition. |
- treehfd.cartesian_partition.CartesianTreePartition(main_variables: ndarray) None
Cartesian tree partition.
This class defines the Cartesian tree partitions of a given tree from the splitting variables and values.
- treehfd.cartesian_partition.main_variables
List of variable indices for main effects.
- Type:
np.ndarray
- treehfd.cartesian_partition.partition_index
Indices of all main effect partitions.
- Type:
np.ndarray
- treehfd.cartesian_partition.split_list
List of splitting values for all main effects.
- Type:
list
- treehfd.cartesian_partition.cell_list
List of array of cell indices for each component.
- Type:
list
- treehfd.cartesian_partition.counts_list
List of sizes of each cell of interaction partitions.
- Type:
list
- treehfd.cartesian_partition.CartesianTreePartition.compute_cartesian_partition(self, X: ndarray, tree_structure: tuple[ndarray, ndarray, ndarray], interaction_list: list[list[int]]) ndarray
Compute Cartesian tree partitions from tree structure and data.
- Parameters:
X (np.ndarray) – The input data used to train the xgboost model.
tree_structure (tuple) – Tuple containing the splitting variables, children node indices, and splitting values of the tree.
interaction_list (list) – List of variable index pairs, with a pair for each interaction.
- Returns:
X_bin – Array with the cell indices of all Cartesian partitions for each training point.
- Return type:
np.ndarray
- treehfd.cartesian_partition.CartesianTreePartition.compute_partition_main(self, X: ndarray, variables: ndarray, split_values: ndarray) ndarray
Compute Cartesian tree partitions of main effects.
- Parameters:
X (np.ndarray) – The input data used to train the xgboost model.
variables (np.ndarray) – Array with the splitting variables of the tree.
split_values (np.ndarray) – Array with the splitting values of the tree.
- Returns:
X_bin_main – Array with the cell indices of main-effect partitions for each training point.
- Return type:
np.ndarray
- treehfd.cartesian_partition.CartesianTreePartition.compute_partition_order2(self, X_bin_main: ndarray, interaction_list: list[list[int]]) ndarray
Compute Cartesian tree partitions of second-order interactions.
- Parameters:
X_bin_main (np.ndarray) – Array with the cell indices of main-effect partitions for each training point.
interaction_list (list) – List of variable index pairs, with a pair for each interaction.
- Returns:
X_bin_order2 – Array with the cell indices of second-order partitions for each training point.
- Return type:
np.ndarray
- treehfd.cartesian_partition.CartesianTreePartition.predict_partition(self, X_new: ndarray, interaction_list: list[list[int]]) tuple[ndarray, ndarray]
Predict cells of the Cartesian tree partitions for new input data.
- Parameters:
X_new (np.ndarray) – New input data where TreeHFD predictions are computed.
interaction_list (list) – List of variable index pairs, with a pair for each interaction.
- Returns:
- X_bin_mainnp.ndarray
Array with the cell indices of main-effect partitions for the new input data.
- X_bin_order2np.ndarray
Array with the cell indices of interaction partitions for the new input data.
- Return type:
tuple