NormalizeFeatures
¶
Bases: FeaturesNormalizedTransform
Row-normalizes the given attributes to sum up to one, as PyG's
NormalizeFeatures.
Each attribute is first shifted by its global minimum, so that all its values are non-negative, then every row is divided by its sum (rows that sum to less than one are divided by one):
\[
\mathbf{x}_i \leftarrow \frac{\mathbf{x}_i - \min(\mathbf{X})}
{\max\left(1, \sum_j (x_{ij} - \min(\mathbf{X}))\right)}
\]
This is the PyG-named equivalent of FeaturesNormalizedTransform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attrs
|
List[str]
|
Names of the attributes to normalize. PyG names ( |
['node_features']
|
Example:
graph = GraphData(
edge_index=mx.array([[0, 1], [1, 0]]),
node_features=mx.array([[1.0, 3.0], [0.0, 0.0]]),
)
graph = NormalizeFeatures()(graph)
graph.node_features
# mx.array([[0.25, 0.75], [0.0, 0.0]])
Source code in mlx_graphs/transforms/normalize_features.py
from mlx_graphs.transforms import NormalizeFeatures · mlx_graphs/transforms/normalize_features.py