OneHotDegree
¶
Bases: BaseTransform
Adds the one-hot encoded degree of each node to the node features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_degree
|
int
|
Maximum degree of the graph(s). The encoding has
|
required |
in_degree
|
bool
|
If |
False
|
cat
|
bool
|
If |
True
|
Example:
graph = GraphData(edge_index=mx.array([[0, 0, 1], [1, 2, 2]]))
graph = OneHotDegree(max_degree=2)(graph)
graph.node_features
# mx.array([[0, 0, 1], [0, 1, 0], [1, 0, 0]])
Methods:
| Name | Description |
|---|---|
process |
Adds the one-hot degrees to the node features of |
Source code in mlx_graphs/transforms/features.py
process
¶
Adds the one-hot degrees to the node features of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph with the updated |
Source code in mlx_graphs/transforms/features.py
from mlx_graphs.transforms import OneHotDegree · mlx_graphs/transforms/features.py