-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
49 lines (40 loc) · 1.42 KB
/
test.py
File metadata and controls
49 lines (40 loc) · 1.42 KB
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
42
43
44
45
46
47
48
49
import networkx as nx
import numpy as np
from generate_dataset import *
from process_data import preprocess
from eigen import eig, define_laplacian
from scipy import spatial
from similarity_algorithms import euclidean_distance
from scipy.spatial import distance
def positive_negative_samples_test():
Z = []
#sample number in DD.mat dataset
x = 2
i = 0
# i defines the number of samples variations we want to create for a matrix
while i < 20:
#append the xth Adj matrix from dataset
Z.append(preprocess(x))
i+=1
# starting to make variations to all matrix except first one
j = 1
while j < 20:
#generate negative/positive samples and modify the Z[j] matrix
#generate_negative(Z[j])
generate_positive(Z[j])
j+=1
i = 0
#comparing with all negative matrices
j = 1
while j < 20:
Z1_x = nx.from_numpy_matrix(Z[i])
Z2_x = nx.from_numpy_matrix(Z[j])
# compute the laplacian and eigen values
lap1=eig(Z1_x, "eigvalsh")
lap2=eig(Z2_x, "eigvalsh")
#import ipdb; ipdb.set_trace()
print('Variation {} - {}'.format(j, 1 - spatial.distance.cosine(lap1,lap2)))
print('Variation {} - {}'.format(j, distance.euclidean(lap1,lap2)))
print('Variation {} - {}'.format(j, distance.minkowski(lap1,lap2)))
j+=1
positive_negative_samples_test()