aboutsummaryrefslogtreecommitdiff
path: root/source/testclusters.py
blob: 6feabfc8c32758b387ac1ccb708e94f887568e6b (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.euclidian)
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