forked from compbiolabucf/omicsGAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcls_utils.py
43 lines (25 loc) · 991 Bytes
/
cls_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
import numpy as np
import torch
import pandas as pd
from scipy.sparse import csr_matrix
from sklearn.metrics import roc_auc_score
def roc_score(output, labels):
preds = output[:,1]
out_arr = preds.cpu().detach().numpy()
labels_arr = labels.cpu().detach().numpy()
score = roc_auc_score(labels_arr, out_arr)
return score
def load_data():
X_load = pd.read_csv('brca_data/feature_matrix.csv')
Y_load = pd.read_csv('brca_data/labels.csv', index_col=0)
adj = pd.read_csv('brca_data/adjacency_matrix.csv', index_col=0)
Y_load.replace(to_replace={'Positive', 'Negative'}, value ={1,0}, inplace = True)
return X_load, Y_load, adj
def process_data(X, Y, adj):
features = csr_matrix(X)
labels = np.array(Y)
adj = csr_matrix(adj)
adj = torch.FloatTensor(np.array(adj.todense()))
features = torch.FloatTensor(np.array(features.todense()))
labels = torch.LongTensor(labels)
return adj, features, labels