MCPcopy
hub / github.com/dmlc/dgl / process

Method process

python/dgl/data/fraud.py:117–145  ·  view source on GitHub ↗

process raw data to graph, labels, splitting masks

(self)

Source from the content-addressed store, hash-verified

115 )
116
117 def process(self):
118 """process raw data to graph, labels, splitting masks"""
119 file_path = os.path.join(self.raw_path, self.file_names[self.name])
120
121 data = io.loadmat(file_path)
122 node_features = data["features"].todense()
123 # remove additional dimension of length 1 in raw .mat file
124 node_labels = data["label"].squeeze()
125
126 graph_data = {}
127 for relation in self.relations[self.name]:
128 adj = data[relation].tocoo()
129 row, col = adj.row, adj.col
130 graph_data[
131 (self.node_name[self.name], relation, self.node_name[self.name])
132 ] = (row, col)
133 g = heterograph(graph_data)
134
135 g.ndata["feature"] = F.tensor(
136 node_features, dtype=F.data_type_dict["float32"]
137 )
138 g.ndata["label"] = F.tensor(
139 node_labels, dtype=F.data_type_dict["int64"]
140 )
141 self.graph = g
142
143 self._random_split(
144 g.ndata["feature"], self.seed, self.train_size, self.val_size
145 )
146
147 def __getitem__(self, idx):
148 r"""Get graph object

Callers

nothing calls this directly

Calls 3

_random_splitMethod · 0.95
heterographFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected