-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathadj.py
27 lines (19 loc) · 913 Bytes
/
adj.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
import pickle as pickle
import numpy as np
dataset=pickle.load(open('dataset/rap2_dataset.pkl','rb'))
partition=pickle.load(open('dataset/rap2_partition.pkl','rb'))
item=[np.array(dataset['att'][idx])[dataset['selected_attribute']] for idx in partition['train'][0]]
sum=np.sum(item,axis=0)
#print(sum)
concur=np.zeros((len(dataset['selected_attribute']),len(dataset['selected_attribute'])))
#print(concur)
for idx in partition['train'][0]:
t=np.array(dataset['att'][idx])[dataset['selected_attribute']]
for i in range(len(np.array(dataset['att'][idx])[dataset['selected_attribute']])):
if t[i]==1:
for j in range(len(np.array(dataset['att'][idx])[dataset['selected_attribute']])):
if t[j]==1 and j!=i:
concur[i][j]+=1
data={'nums':sum,'adj':concur}
with open('dataset/adj.pkl','wb+') as f:
pickle.dump(data,f)