-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_kernel_k_means.py
More file actions
38 lines (25 loc) · 821 Bytes
/
main_kernel_k_means.py
File metadata and controls
38 lines (25 loc) · 821 Bytes
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
import sys
from LoadData import *
from k_means import *
from evaluation import *
from kernel_k_means import *
if __name__ == "__main__":
if len(sys.argv) != 3:
print "[usage] <data-file> <ground-truth-file>"
exit(1)
dataFilename = sys.argv[1]
groundtruthFilename = sys.argv[2]
data = loadPoints(dataFilename)
groundtruth = loadClusters(groundtruthFilename)
sigma = 4.0
data = kernel(data, sigma)
nDim = len(data[0])
K = 2 # Suppose there are 2 clusters
centers = []
centers.append(data[0])
centers.append(data[1])
results = kmeans(data, centers)
res_Purity = purity(results, groundtruth)
res_NMI = NMI(results, groundtruth)
print "Purity =", res_Purity
print "NMI = ", res_NMI