aboutsummaryrefslogtreecommitdiff
path: root/source/testclusters.py
blob: ea6406b1ee013a832c18a4ffffaf2649c472f666 (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 = 8

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

coords = clusters.scaledown(data)

print "Generating clusters..."
kclust = clusters.kcluster(data, k=K)
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