topobench.transforms.data_manipulations package#
Submodules#
topobench.transforms.data_manipulations.calculate_simplicial_curvature module#
A transform that calculates the simplicial curvature of the input graph.
- class topobench.transforms.data_manipulations.calculate_simplicial_curvature.CalculateSimplicialCurvature(**kwargs)[source]#
Bases:
BaseTransform
A transform that calculates the simplicial curvature of the input graph.
- Parameters:
- **kwargsoptional
Parameters for the transform.
- forward(data: Data)[source]#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- one_cell_curvature(data: Data) Data [source]#
Calculate the one cell curvature of the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
Data with the one cell curvature.
topobench.transforms.data_manipulations.equal_gaus_features module#
This module contains a transform that generates equal Gaussian features for all nodes in the input graph.
- class topobench.transforms.data_manipulations.equal_gaus_features.EqualGausFeatures(**kwargs)[source]#
Bases:
BaseTransform
A transform that generates equal Gaussian features for all nodes.
- Parameters:
- **kwargsoptional
Additional arguments for the class. It should contain the following keys: - mean (float): The mean of the Gaussian distribution. - std (float): The standard deviation of the Gaussian distribution. - num_features (int): The number of features to generate.
topobench.transforms.data_manipulations.group_homophily module#
A transform that canculates group combinatorial homophily of the input hypergraph.
- class topobench.transforms.data_manipulations.group_homophily.GroupCombinatorialHomophily(**kwargs)[source]#
Bases:
BaseTransform
Calculates group combinatorial homophily of the input hypergraph.
This transformation implements the methodology from the paper: “Combinatorial Characterizations and Impossibilities for Higher-order Homophily”. It computes homophily metrics for hypergraphs by analyzing the relationship between node labels within hyperedges.
- Parameters:
- **kwargsdict, optional
Additional parameters for the transform. - top_k : int, default=3
Number of top hyperedge cardinalities to analyze.
- Attributes:
- typestr
Identifier for the transform type.
- top_kint
Number of top hyperedge cardinalities to analyze.
- calculate_D_matrix(H, labels, he_cardinalities, unique_labels, class_node_idxs)[source]#
Calculate the degree matrices D and D_t for the hypergraph.
- Parameters:
- Htorch.Tensor
Dense incidence matrix of the hypergraph.
- labelstorch.Tensor
Node labels.
- he_cardinalitiestorch.Tensor
Cardinality of each hyperedge.
- unique_labelsdict
Dictionary mapping labels to their counts.
- class_node_idxsdict
Dictionary mapping labels to node indices.
- Returns:
- tuple[torch.Tensor, torch.Tensor]
D_t_class : Type-t degree distribution matrix for each class
D : Degree matrix counting same-label nodes in hyperedges
- calculate_affinity_score(n_nodes, X_mod, t, k)[source]#
Calculate affinity score.
- Parameters:
- n_nodesint
Total number of nodes.
- X_modint
Total number of nodes in a class.
- tint
Type-t degree.
- kint
Max hyperedge cardinality.
- Returns:
- torch.Tensor
The affinity matrix.
- calculate_baseline_matrix(he_cardinalities, unique_labels, class_node_idxs, count_labels, n_nodes)[source]#
Calculate the baseline affinity matrix for comparison.
- Parameters:
- he_cardinalitiestorch.Tensor
Cardinality of each hyperedge.
- unique_labelsdict
Dictionary mapping labels to their counts.
- class_node_idxsdict
Dictionary mapping labels to node indices.
- count_labelstorch.Tensor
Count of nodes for each label.
- n_nodesint
Total number of nodes in the hypergraph.
- Returns:
- torch.Tensor
Baseline matrix containing expected affinity scores for each class and degree type.
topobench.transforms.data_manipulations.identity_transform module#
Identity transform that does nothing to the input data.
topobench.transforms.data_manipulations.infere_knn_connectivity module#
InfereKNNConnectivity class definition.
- class topobench.transforms.data_manipulations.infere_knn_connectivity.InfereKNNConnectivity(**kwargs)[source]#
Bases:
BaseTransform
Transform to infer point cloud connectivity.
The transform generates the k-nearest neighbor connectivity of the input point cloud.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
topobench.transforms.data_manipulations.infere_radius_connectivity module#
InfereRadiusConnectivity class definition.
- class topobench.transforms.data_manipulations.infere_radius_connectivity.InfereRadiusConnectivity(**kwargs)[source]#
Bases:
BaseTransform
Class to infer point cloud connectivity.
The transform generates the radius connectivity of the input point cloud.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
topobench.transforms.data_manipulations.keep_only_connected_component module#
KeepOnlyConnectedComponent class definition.
topobench.transforms.data_manipulations.keep_selected_data_fields module#
A transform that keeps only the selected fields of the input data.
topobench.transforms.data_manipulations.mp_homophily module#
A transform that canculates message passing homophily of the input hypergraph.
- class topobench.transforms.data_manipulations.mp_homophily.MessagePassingHomophily(**kwargs)[source]#
Bases:
BaseTransform
Calculates message passing homophily of the input data.
This transformation implements the methodology from the paper: “Hypergraph Neural Networks through the Lens of Message Passing: A Common Perspective to Homophily and Architecture Design”. It computes homophily metrics for hypergraphs by analyzing the relationship between node labels within hyperedges.
- Parameters:
- **kwargsdict, optional
Additional parameters for the transform. - top_k : int, default=3
Number of top hyperedge cardinalities to analyze.
- Attributes:
- typestr
Identifier for the transform type.
- top_kint
Number of top hyperedge cardinalities to analyze.
topobench.transforms.data_manipulations.node_degrees module#
Node degrees transform.
- class topobench.transforms.data_manipulations.node_degrees.NodeDegrees(**kwargs)[source]#
Bases:
BaseTransform
A transform that calculates the node degrees of the input graph.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
topobench.transforms.data_manipulations.node_features_to_float module#
A transform that converts the node features of the input graph to float.
topobench.transforms.data_manipulations.one_hot_degree_features module#
One hot degree features transform.
- class topobench.transforms.data_manipulations.one_hot_degree_features.OneHotDegreeFeatures(max_degree: int, degrees_fields: str, features_fields: str, cat: bool = False, **kwargs)[source]#
Bases:
BaseTransform
Class for one hot degree features transform.
A transform that adds the node degree as one hot encodings to the node features.
- Parameters:
- max_degreeint
The maximum degree of the graph.
- degrees_fieldsstr
The field containing the node degrees.
- features_fieldsstr
The field containing the node features.
- catbool, optional
If set to True, the one hot encodings are concatenated to the node features (default: False).
- **kwargsoptional
Additional arguments for the class.
topobench.transforms.data_manipulations.redefine_simplicial_neighbourhoods module#
An transform that redifines simplicial complex neighbourhood.
Module contents#
Data manipulations module with automated exports.
- class topobench.transforms.data_manipulations.CalculateSimplicialCurvature(**kwargs)#
Bases:
BaseTransform
A transform that calculates the simplicial curvature of the input graph.
- Parameters:
- **kwargsoptional
Parameters for the transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- one_cell_curvature(data: Data) Data #
Calculate the one cell curvature of the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
Data with the one cell curvature.
- two_cell_curvature(data: Data) Data #
Calculate the two cell curvature of the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
Data with the two cell curvature.
- zero_cell_curvature(data: Data) Data #
Calculate the zero cell curvature of the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
Data with the zero cell curvature.
- class topobench.transforms.data_manipulations.EqualGausFeatures(**kwargs)#
Bases:
BaseTransform
A transform that generates equal Gaussian features for all nodes.
- Parameters:
- **kwargsoptional
Additional arguments for the class. It should contain the following keys: - mean (float): The mean of the Gaussian distribution. - std (float): The standard deviation of the Gaussian distribution. - num_features (int): The number of features to generate.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.GroupCombinatorialHomophily(**kwargs)#
Bases:
BaseTransform
Calculates group combinatorial homophily of the input hypergraph.
This transformation implements the methodology from the paper: “Combinatorial Characterizations and Impossibilities for Higher-order Homophily”. It computes homophily metrics for hypergraphs by analyzing the relationship between node labels within hyperedges.
- Parameters:
- **kwargsdict, optional
Additional parameters for the transform. - top_k : int, default=3
Number of top hyperedge cardinalities to analyze.
- Attributes:
- typestr
Identifier for the transform type.
- top_kint
Number of top hyperedge cardinalities to analyze.
- calculate_D_matrix(H, labels, he_cardinalities, unique_labels, class_node_idxs)#
Calculate the degree matrices D and D_t for the hypergraph.
- Parameters:
- Htorch.Tensor
Dense incidence matrix of the hypergraph.
- labelstorch.Tensor
Node labels.
- he_cardinalitiestorch.Tensor
Cardinality of each hyperedge.
- unique_labelsdict
Dictionary mapping labels to their counts.
- class_node_idxsdict
Dictionary mapping labels to node indices.
- Returns:
- tuple[torch.Tensor, torch.Tensor]
D_t_class : Type-t degree distribution matrix for each class
D : Degree matrix counting same-label nodes in hyperedges
- calculate_affinity_score(n_nodes, X_mod, t, k)#
Calculate affinity score.
- Parameters:
- n_nodesint
Total number of nodes.
- X_modint
Total number of nodes in a class.
- tint
Type-t degree.
- kint
Max hyperedge cardinality.
- Returns:
- torch.Tensor
The affinity matrix.
- calculate_baseline_matrix(he_cardinalities, unique_labels, class_node_idxs, count_labels, n_nodes)#
Calculate the baseline affinity matrix for comparison.
- Parameters:
- he_cardinalitiestorch.Tensor
Cardinality of each hyperedge.
- unique_labelsdict
Dictionary mapping labels to their counts.
- class_node_idxsdict
Dictionary mapping labels to node indices.
- count_labelstorch.Tensor
Count of nodes for each label.
- n_nodesint
Total number of nodes in the hypergraph.
- Returns:
- torch.Tensor
Baseline matrix containing expected affinity scores for each class and degree type.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.IdentityTransform(**kwargs)#
Bases:
BaseTransform
An identity transform that does nothing to the input data.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The same data.
- class topobench.transforms.data_manipulations.InfereKNNConnectivity(**kwargs)#
Bases:
BaseTransform
Transform to infer point cloud connectivity.
The transform generates the k-nearest neighbor connectivity of the input point cloud.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.InfereRadiusConnectivity(**kwargs)#
Bases:
BaseTransform
Class to infer point cloud connectivity.
The transform generates the radius connectivity of the input point cloud.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.KeepOnlyConnectedComponent(**kwargs)#
Bases:
BaseTransform
Class to keep only the largest connected components of the input graph.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.KeepSelectedDataFields(**kwargs)#
Bases:
BaseTransform
A transform that keeps only the selected fields of the input data.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.MessagePassingHomophily(**kwargs)#
Bases:
BaseTransform
Calculates message passing homophily of the input data.
This transformation implements the methodology from the paper: “Hypergraph Neural Networks through the Lens of Message Passing: A Common Perspective to Homophily and Architecture Design”. It computes homophily metrics for hypergraphs by analyzing the relationship between node labels within hyperedges.
- Parameters:
- **kwargsdict, optional
Additional parameters for the transform. - top_k : int, default=3
Number of top hyperedge cardinalities to analyze.
- Attributes:
- typestr
Identifier for the transform type.
- top_kint
Number of top hyperedge cardinalities to analyze.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.NodeDegrees(**kwargs)#
Bases:
BaseTransform
A transform that calculates the node degrees of the input graph.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- calculate_node_degrees(data: Data, field: str) Data #
Calculate the node degrees of the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- fieldstr
The field to calculate the node degrees.
- Returns:
- torch_geometric.data.Data
The transformed data.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.NodeFeaturesToFloat(**kwargs)#
Bases:
BaseTransform
A transform that converts the node features of the input graph to float.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.OneHotDegreeFeatures(max_degree: int, degrees_fields: str, features_fields: str, cat: bool = False, **kwargs)#
Bases:
BaseTransform
Class for one hot degree features transform.
A transform that adds the node degree as one hot encodings to the node features.
- Parameters:
- max_degreeint
The maximum degree of the graph.
- degrees_fieldsstr
The field containing the node degrees.
- features_fieldsstr
The field containing the node features.
- catbool, optional
If set to True, the one hot encodings are concatenated to the node features (default: False).
- **kwargsoptional
Additional arguments for the class.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- class topobench.transforms.data_manipulations.RedefineSimplicialNeighbourhoods(**kwargs)#
Bases:
BaseTransform
An transform that redifines simplicial complex neighbourhood.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- forward(data: Data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The same data.