kcell.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:jamespy_py3 作者: jskDr 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号