aboutsummaryrefslogtreecommitdiff
path: root/source/testclusters.py
blob: 728e9c1b2766dbafa9debe628366bd92e0dacca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /usr/bin/env python
#-*- 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