Commit 9c2c1adc authored by Taddeüs Kroes's avatar Taddeüs Kroes

StatRed ass4: Source code cleanup.

parent 512148cf
from pylab import loadtxt, array, scatter, figure, show, mean, argmin, \ from pylab import loadtxt, array, scatter, figure, show, mean, argmin, append
append, savefig
from random import random, seed from random import random, seed
from sys import argv, exit from sys import argv, exit
...@@ -47,7 +46,7 @@ if not pp: ...@@ -47,7 +46,7 @@ if not pp:
print 'Using normal k-means' print 'Using normal k-means'
initial_means = init initial_means = init
k = int(argv[1]) k = int(argv[1])
if k < 1 or k > 6: if not 1 <= k <= 6:
print 'K must be a value from 1-6' print 'K must be a value from 1-6'
exit() exit()
...@@ -83,5 +82,4 @@ colors = [[1,0,0], [0,1,0], [0,0,1], [0,0,0], [1,1,1], [.5,.5,.5]] ...@@ -83,5 +82,4 @@ colors = [[1,0,0], [0,1,0], [0,0,1], [0,0,0], [1,1,1], [.5,.5,.5]]
for i in range(k): for i in range(k):
c = array(clusters[i]) c = array(clusters[i])
scatter(c[:,0], c[:,1], c=colors[i]) scatter(c[:,0], c[:,1], c=colors[i])
savefig('k-means.pdf')
show() show()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment