[SciPy-User] kmeans2 question/issue
James Abel
j at abel.co
Sat Aug 11 14:19:04 EDT 2012
Thanks - sklearn works great! I got exactly what I expected each time I ran
it!
James
import sys
import numpy
from sklearn.cluster import *
print sys.version
vals = numpy.array([[0.0],[0.1],[0.5],[0.6],[1.0],[1.1]])
print vals
k_means_ex = KMeans(k=3)
x = k_means_ex.fit_predict(vals)
print x
print k_means_ex.cluster_centers_
print k_means_ex.score(vals)
2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
[[ 0. ]
[ 0.1]
[ 0.5]
[ 0.6]
[ 1. ]
[ 1.1]]
[1 1 0 0 2 2]
[[ 0.55]
[ 0.05]
[ 1.05]]
-0.015
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120811/4c2aea18/attachment.html>
More information about the SciPy-User
mailing list