aboutsummaryrefslogtreecommitdiff
path: root/source/testclusters.py
blob: a16d34928a6b5f36bb9c16498fb89e5bf4ef5a5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-

import clusters

K = 7

blognames,words,data = clusters.readfile("blogdata1.txt")

coords = clusters.scaledown(data)

print "Generating clusters..."
kclust = clusters.kcluster(data, k=K, distance=clusters.pearson)
print
print "Clusters:"
for i in range(K):
    print "Cluster" + str(i)
    print ", ".join([blognames[r] for r in kclust[i]])
    print




clusters.draw2d(coords,blognames,jpeg='mds2d.jpg')
bgstack15