FeaturePropagation
¶
Bases: BaseTransform
Fills in missing node features by propagating the known ones, with the
feature propagation algorithm from "On the Unreasonable Effectiveness of Feature propagation in Learning on Graphs with Missing Node Features", as PyG's FeaturePropagation:
where \(\mathbf{M}\) is the mask of the missing features and
\(\mathbf{D}\) is the weighted in-degree. The edge weights are taken
from edge_weights if it exists, otherwise from edge_features if it
holds one scalar per edge (as PyG uses edge_attr), and are ones
otherwise. No self-loops are added, and the weights of duplicate edges are
summed (PyG instead collapses duplicate edges when the graph has no
weights).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
missing_mask
|
Union[array, ndarray]
|
Boolean mask of shape |
required |
num_iterations
|
int
|
Number of propagation steps. Default: |
40
|
Example:
node_features = mx.array([[1.0], [float("nan")], [3.0]])
graph = GraphData(
edge_index=mx.array([[0, 1, 1, 2], [1, 0, 2, 1]]),
node_features=node_features,
)
graph = FeaturePropagation(mx.isnan(node_features))(graph)
graph.node_features
# mx.array([[1.0], [2.8284], [3.0]]), i.e. (1 + 3) / sqrt(2)
Methods:
| Name | Description |
|---|---|
process |
Fills in the missing node features of |
Source code in mlx_graphs/transforms/propagation.py
process
¶
Fills in the missing node features of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph with the completed |
Source code in mlx_graphs/transforms/propagation.py
from mlx_graphs.transforms import FeaturePropagation · mlx_graphs/transforms/propagation.py