-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
50 lines (38 loc) · 1.15 KB
/
main.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
42
43
44
45
46
47
48
49
50
from clusteringUtils import *
if __name__ == '__main__':
#load the data to use
cube = np.load("npIndian_pines.npy")
#get the unrolled data for the kmeans
data = np.load("data.npy")
#get the ground truth
gt = np.load("npIndian_pines_gt.npy")
#convert
key = ConvertGroundtruth(gt)
labels = kMeansMaxSpectralWeight(cube,data,gt,key)
print("Doing Neighborhood Biasing..")
evo0 = ConvertLabels(labels)
evo1 = NeighborBias(evo0,numClasses,1)
i=0
for i in range(10):
evo2 = NeighborBias(evo1,numClasses,1)
if np.array_equal(evo1,evo2):
print("Converged!")
evo1 = evo2
labels = ConvertGroundtruth(evo2)
# Rand Index
print("Calculating Rand Index..")
print(RandIndex(labels,key))
# Adjusted rand index
print("Calculating Adjusted Rand Index..")
print(adjusted_rand_score(labels,key))
# Visualize Ground Truth Prediction
plt.ion()
fig = plt.figure()
plt.imshow(gt)
plt.show()
# Visualize the clustering output
fig3 = plt.figure()
plt.imshow(evo1)
plt.show()
#Hold so you can see the graphs at the end
input()