public
Description: wiimote gesture recognition library
Homepage:
Clone URL: git://github.com/jbm9/wii_gestures.git
wii_gestures / noodling / process / kmeans.py
100755 10 lines (8 sloc) 0.493 kb
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env python
#this little one linner preprocesses the data as dumped by "wmdump" into something that python can diggest
#for i in ../training-data-capture-20090610/*; do awk -F '[=, ]' 'BEGIN { print "data = [" } /Acc/ { printf "[%s, %s, %s],\n", $4, $7, $10 } END { print "]" }' "$i"; done > data.py
 
import numpy
from scipy.cluster.vq import kmeans2
from data import data
points, res = kmeans2(numpy.array(data, dtype=float), 3)
print 'points: %s\n\n\nresults: %s' % (points, res)