Power Grid datasets
GridDatasetMem
¶
Bases: InMemoryDataset
A PyTorch Geometric InMemoryDataset
for power grid data stored in tabular CSV format.
This dataset class reads node and edge data from CSV files, applies normalization using
user-specified Normalizer
instances, and builds graph data objects with edge weights and
positional encodings.
- Reads raw node and edge CSV files (
pf_node.csv
,pf_edge.csv
). - Applies the normalization method specified on both node and edge features
- Stores normalization statistics in the
processed
directory for reuse. - Constructs
torch_geometric.data.Data
objects with edge weights and positional encodings (via random walk embeddings).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
str
|
Root directory where the dataset is stored. |
required |
norm_method
|
str
|
Identifier for normalization method (e.g., "minmax", "standard"). |
required |
node_normalizer
|
Normalizer
|
Normalizer used for node features. |
required |
edge_normalizer
|
Normalizer
|
Normalizer used for edge features. |
required |
pe_dim
|
int
|
Length of the random walk used for positional encoding. |
required |
mask_dim
|
int
|
Number of features per-node that could be masked. Usually Pd, Qd, Pg, Qg, Vm, Va |
6
|
transform
|
callable
|
Transformation applied at runtime. |
None
|
pre_transform
|
callable
|
Transformation applied before saving to disk. |
None
|
pre_filter
|
callable
|
Filter to determine which graphs to keep. |
None
|
Source code in gridfm_graphkit/datasets/powergrid.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
change_transform(new_transform)
¶Temporarily switch to a new transform function, used when evaluating different tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_transform
|
Callable
|
The new transform to use. |
required |
Source code in gridfm_graphkit/datasets/powergrid.py
174 175 176 177 178 179 180 181 182 |
|
reset_transform()
¶Reverts the transform to the original one set during initialization, usually called after the evaluation step.
Source code in gridfm_graphkit/datasets/powergrid.py
184 185 186 187 188 189 190 191 192 |
|
Usage Example¶
from gridfm_graphkit.datasets.data_normalization import IdentityNormalizer
from gridfm_graphkit.datasets.powergrid import GridDatasetMem
dataset = GridDatasetMem(
root="./data",
norm_method="identity",
node_normalizer=IdentityNormalizer(),
edge_normalizer=IdentityNormalizer(),
pe_dim=10,
mask_dim=6,
)