You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
node_y (Tensor | None): Node labels over time [num_node_labels, D_node_dynamic].
60
63
static_node_x (Tensor | None): Node features invariant over time [num_nodes, D_node_static].
64
+
edge_type (Tensor | None) : Type of relation of each edge event in edge_index [num_edge_events].
65
+
node_type (Tensor | None) : Type of each node [num_nodes].
61
66
62
67
Raises:
63
68
InvalidNodeIDError: If an edge or node ID match `PADDED_NODE_ID`.
69
+
InvalidNodeIDError: If node labels exists with node IDs outside the graph's node ID range.
64
70
ValueError: If any data attributes have non-well defined tensor shapes.
65
71
EmptyGraphError: If attempting to initialize an empty graph.
66
72
67
73
Notes:
68
74
- Timestamps must be non-negative and sorted; DGData will sort automatically if necessary.
69
75
- Cloning creates a deep copy of tensors to prevent in-place modifications.
76
+
- Edge type is only applicable for Heterogeneous & Knowledge graph.
77
+
- Node type is only applicable for Knowledge graph.
70
78
"""
71
79
```
72
80
@@ -114,10 +122,14 @@ Please consult our documentation for full description of our API. The table belo
114
122
|`edge_src_col`| Column name in edge file for src nodes |`str`| Yes | Cannot have ids matching `tgm.constants.PADDED_NODE_ID`|
115
123
|`edge_dst_col`| Column name in edge file for dst nodes |`str`| Yes | Cannot have ids matching `tgm.constants.PADDED_NODE_ID`|
116
124
|`edge_time_col`| Column name in edge file for edge times |`str`| Yes | Time must be non-negative |
117
-
|`node_file_path`| Path to CSV file containing dynamic node data |`str \| pathlib.Path`| No |`node_df` is using `from_pandas`|
118
-
|`node_x_nids_col`| Column name in node file for node event node ids |`str`| No, unless `node_file_path` is specified| Cannot have ids matching `tgm.constants.PADDED_NODE_ID`|
119
-
|`node_x_time_col`| Column name in node file for node event node times |`str`| No, unless `node_file_path` is specified| Time must be non-negative |
125
+
|`node_x_file_path`| Path to CSV file containing dynamic node data |`str \| pathlib.Path`| No |`node_x_df` is using `from_pandas`|
126
+
|`node_x_nids_col`| Column name in node file for node event node ids |`str`| No, unless `node_x_file_path` is specified | Cannot have ids matching `tgm.constants.PADDED_NODE_ID`|
127
+
|`node_x_time_col`| Column name in node file for node event node times |`str`| No, unless `node_x_file_path` is specified | Time must be non-negative |
120
128
|`node_x_col`| Column name in node file for dynamic node features |`str`| No ||
129
+
|`node_y_file_path`| Path to CSV file containing dynamic node labels |`str \| pathlib.Path`| No |`node_y_df` is using `from_pandas`|
130
+
|`node_y_nids_col`| Column name in node file for node label node ids |`str`| No, unless `node_y_file_path` is specified | Cannot have ids matching `tgm.constants.PADDED_NODE_ID`|
131
+
|`node_y_time_col`| Column name in node file for node label node times |`str`| No, unless `node_y_file_path` is specified | Time must be non-negative |
132
+
|`node_y_col`| Column name in node file for dynamic node labels |`str`| No ||
121
133
|`static_node_x_file_path`| Path to CSV file containing static node features |`str \| pathlib.Path`| No |`static_node_x_df` if using `from_pandas`|
122
134
|`static_node_x_col`| Column name in static node feats file for static node features |`str`| No, unless `static_node_x_file_path` is specified ||
123
135
|`time_delta`| Time granularity of the graph data |`TimeDeltaDG \| str`| Yes | Default to *event_ordered* granularity `'r'`|
@@ -131,16 +143,18 @@ A few key things to know:
131
143
- We expect an `edge_file_path` which is a csv file with `edge_src_col`, `edge_dst_col`, `edge_time_col` as a minimum.
132
144
- Your edge csv file may also contain `edge_x_col` which are the edge features on your data
133
145
- dynamic node data (optional)
134
-
- If included, we expect a `node_file_path` which is a csv file with `node_x_nids_col`, `node_x_time_col` as a minimum. These are your dynamic node events.
146
+
- If included, we expect a `node_x_file_path` which is a csv file with `node_x_nids_col`, `node_x_time_col` as a minimum. These are your dynamic node events.
147
+
- If included, we expect a `node_y_file_path` which is a csv file with `node_y_nids_col`, `node_y_time_col` as a minimum. These are your dynamic node labels.
135
148
- Your dynamic node data csv file may also include `node_x_col`, which are the dynamic node features in your data.
149
+
- Your dynamic node labels csv file may also include `node_y_col`, which are the dynamic node labels in your data.
136
150
- static node data (optional)
137
151
- If included, we expect a `static_node_x_file_path` which is a csv file with `static_node_x_col`, the static node features for your dataset.
138
152
139
153
Internally, we perform various checks on the tensors shapes, node ranges, and timestamps values. If your data is well structured, everything should work. If you get an error message that is not intuitive, please let us know.
140
154
141
155
#### From Pandas
142
156
143
-
The API largely the same as above, except that we expected `edge_df`, `node_df`, and `static_node_x_df` dataframes for the edge, dynamic node, and static node data respectively, instead of csv files.
157
+
The API largely the same as above, except that we expected `edge_df`, `node_x_df`, and `static_node_x_df` dataframes for the edge, dynamic node, and static node data respectively, instead of csv files.
144
158
145
159
```python
146
160
import pandas as pd
@@ -171,7 +185,7 @@ dg = DGData.from_pandas(
171
185
edge_dst_col='dst',
172
186
edge_time_col='t',
173
187
edge_x_col='edge_feat',
174
-
node_df=dynamic_node_df,
188
+
node_x_df=dynamic_node_df,
175
189
node_x_nids_col='node',
176
190
node_x_time_col='t',
177
191
node_x_col='dynamic_node_feat',
@@ -404,6 +418,9 @@ class DGBatch:
404
418
node_x (Tensor | None, optional): Dynamic node features for nodes in the batch. Tensor of shape `(T x V x d_node_dynamic)`.
0 commit comments