This repository was archived by the owner on Aug 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsetup.py
More file actions
41 lines (33 loc) · 1.3 KB
/
setup.py
File metadata and controls
41 lines (33 loc) · 1.3 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
import matplotlib.pyplot as plt
import data_process
import cluster
GIVEN_DATA = './data/example_distances.dat'
def main():
solution = data_process.ProcessData()
dist, maxid = solution.data_process(GIVEN_DATA)
# threshold = solution.threshold(dist, maxid)
threshold = 0.0456
sort_dst = solution.CutOff(dist, maxid, threshold)
# sort_dst = solution.Guasse(dist, maxid, threshold)
min_dist, min_num = solution.min_distance(dist, sort_dst, maxid)
pair_info, refer_info = solution.make_pair(sort_dst, min_dist, maxid)
solution.show_pair_info(pair_info, threshold)
print('Data process done!')
clust = cluster.DensityPeakCluster()
center, tag = clust.locate_center(refer_info, maxid, threshold)
taginfo = clust.classify(tag, sort_dst, min_num, maxid)
print('Clustering done!')
# show each cluster results
clust.analysis(center, taginfo, dist, maxid)
# show cluster distribution info
temp = sorted(taginfo.items(), key=lambda k:k[1])
y, x = zip(*temp)
# color = { 1:'b', 2:'g', 3:'r', 4:'c', 5:'m', 6:'y'}
plt.scatter(x, y)
plt.xlabel('Cluster Number')
plt.ylabel('Point Number')
plt.title(r'$d_c=$' + str(threshold))
plt.savefig('./images/cluster_cutoff.png')
plt.show()
if __name__ == '__main__':
main()