In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
import glob

tcs = glob.glob('ik-learning/tc/tc-*.npy')
print len(tcs), 'tcs found'


105 tcs found

In [3]:
tc = vstack([load(tc) for tc in tcs])
print 'mega shape', tc.shape


mega shape (105000, 3)

In [4]:
scatter(tc[:, 0], tc[:, 1])


Out[4]:
<matplotlib.collections.PathCollection at 0x10b7e00d0>

In [5]:
scatter(tc[:, 0], tc[:, 2])


Out[5]:
<matplotlib.collections.PathCollection at 0x10bc59450>

In [6]:
scatter(tc[:, 1], tc[:, 2])


Out[6]:
<matplotlib.collections.PathCollection at 0x10bf0de90>

In [7]:
from mpl_toolkits.mplot3d.axes3d import Axes3D

ax = axes(projection='3d')
ax.scatter(* tc.T)


Out[7]:
<mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x10c1fab10>

In [8]:
from sklearn.cluster import KMeans

K = 150

kmeans = KMeans(K)
kmeans.fit(tc)


Out[8]:
KMeans(copy_x=True, init='k-means++', max_iter=300, n_clusters=150, n_init=10,
    n_jobs=1, precompute_distances=True, random_state=None, tol=0.0001,
    verbose=0)

In [9]:
ax = axes(projection='3d')
ax.scatter(* kmeans.cluster_centers_.T)


Out[9]:
<mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x10fa44b10>

In [10]:
save('ik-learning/tc-{}.npy'.format(K), kmeans.cluster_centers_)

In [10]: