Ensemble.py 文件源码

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

项目:molearn 作者: jmread 项目源码 文件源码
def predict_proba(self,X):
        '''
            return confidences (i.e., p(y_j|x)) 
            (in the multi-dimensional output case, this should be an N x L x K array
            but @NOTE/@TODO: this is not the case at the moment! At the moment it is N x L x 2;
            For example, in 
                [[ 0.   1. ]
                 [ 0.   0.9]
                 [ 0.   1. ]
                 [ 0.   1. ]
                 [ 0.   1. ]
                 [ 1.   0.9]]
                y_j=6 with probability 0.9.
            )
        '''
        N,D = X.shape
        Y = zeros((N,self.L,2))
        for i in range(N):
            V = zeros((self.M,self.L))
            for m in range(self.M):
                V[m,:] = self.h[m].predict(array([X[i,:]]))
            k = mode(V)[0]
            Y[i,:,0] = k
            Y[i,:,1] = sum(V==k,axis=0)/self.M
        return Y
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号