def show_both_kmeans( self, c):
X1part = self.X1part
X2part = self.X2part
y = self.y
cell = self.cell
X1_ylim = self.X1_ylim
X2_ylim = self.X2_ylim
cmethod = self.cmethod
cparam_d = self.cparam_d
nc = cparam_d["n_clusters"]
#print("Cluster:", c)
X3_int = X2part[ y==c,:]
X3_vel = X1part[ y==c,:]
#km = cluster.KMeans(2)
#km = getattr(cluster, cmethod)(2)
assert cmethod == "KMeans"
km = cluster.KMeans( nc)
y3 = km.fit_predict( X3_int)
plt.figure(figsize=(9,4))
plt.subplot(1,2,1)
#print("Intensity")
n_l = [ X3_int[ y3==i].shape[0] for i in range(nc)]
for i in range(nc):
sns.tsplot( X3_int[ y3==i,:], color=plt.cm.rainbow(i/nc))
plt.ylim(X2_ylim)
plt.title("Cluster{0}:X2 {1}".format(c, n_l))
#plt.show()
plt.subplot(1,2,2)
#print("Velocity")
for i in range(nc):
sns.tsplot( X3_vel[ y3==i,:], color=plt.cm.rainbow(i/nc))
plt.ylim(X1_ylim)
plt.title("Cluster{0}:X1 {1}".format(c, n_l))
plt.show()
return y3
评论列表
文章目录