komd_gui.py 文件源码

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

项目:EasyMKL 作者: jmikko 项目源码 文件源码
def convex_hull(self, model):
        train = np.array(model.data)
        global t1,t2
        t1,t2 = [],[]

        for i,example in enumerate(train):
            if example[2]==1:
                t1.append(example[0:2])
            else:
                t2.append(example[0:2])
        global ch1,ch2,has_margin
        if (has_margin):
            self.ax.lines.pop(len(t1)+len(t2)-1)
        for i in range(ch1+ch2):
            self.ax.lines.pop(len(t1)+len(t2)-1)
        if len(t1) > 2:
            X1 = np.matrix(np.array(t1))
            hull1 = ConvexHull(X1);    
            for simplex in hull1.simplices:
                self.ax.plot(X1[simplex,0],X1[simplex,1], color='grey',linewidth=1)
            ch1 = len(hull1.simplices)

        if len(t2) > 2:
            X2 = np.matrix(np.array(t2))
            hull2 = ConvexHull(X2);
            for simplex in hull2.simplices:
                self.ax.plot(X2[simplex,0],X2[simplex,1], color='0.25')
            #self.ax.plot(cx2,cy2,'+',ms=10, color="blue")
            ch2 = len(hull2.simplices)
        global isFitted
        #print len(train),"\t"
        #if isFitted:
        #    self.draw_distance(model,model.clf.gamma)
        self.set_dim()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号