kcell.py 文件源码

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

项目:jamespy_py3 作者: jskDr 项目源码 文件源码
def show_both( 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

        #print("Cluster:", c)
        X3_int = X2part[ np.where(y==c)[0],:]
        X3_vel = X1part[ np.where(y==c)[0],:]

        #km = cluster.KMeans(2)
        #km = getattr(cluster, cmethod)(2)
        km = getattr(cluster, cmethod)(**cparam_d)
        y3 = km.fit_predict( X3_int)

        plt.figure(figsize=(9,4))
        plt.subplot(1,2,1)
        #print("Intensity")
        n_0 = X3_int[ np.where( y3==0)[0]].shape[0]
        n_1 = X3_int[ np.where( y3==1)[0]].shape[0]

        sns.tsplot( X3_int[ np.where( y3==0)[0],:], color="blue")
        sns.tsplot( X3_int[ np.where( y3==1)[0],:], color="green")
        plt.ylim(X2_ylim)
        plt.title("Cluster{0}:X2 {1}:{2}".format(c, n_0, n_1))
        #plt.show()

        plt.subplot(1,2,2)
        #print("Velocity")
        sns.tsplot( X3_vel[ np.where( y3==0)[0],:], color="blue")
        sns.tsplot( X3_vel[ np.where( y3==1)[0],:], color="green")
        plt.ylim(X1_ylim)
        plt.title("Cluster{0}:X1 {1}:{2}".format(c, n_0, n_1))
        plt.show()

        cell3 = cell[ np.where(y==c)[0]]
        plt.subplot(1,2,1)
        plt.stem( cell3[np.where( y3==0)[0]], linefmt='b-', markerfmt='bo')
        plt.title("Cell Index - Subcluster 1")
        plt.subplot(1,2,2)
        plt.stem( cell3[np.where( y3==1)[0]], linefmt='g-', markerfmt='go')   
        plt.title("Cell Index - Subcluster 2")
        plt.show()

        return y3
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号