示例#1
0
def reshape_netwise(data_scale):
    # Reshape with the following dim: nSubjects, nfeatures, nfeatures
    for i in range(0,data_scale.shape[0]):
        if i==0:
            all_subjmat = ts.vec2mat(data_scale[i,:])[np.newaxis,...]
        else:        
            all_subjmat = np.vstack((all_subjmat,ts.vec2mat(data_scale[i,:])[np.newaxis,...]))
            
    #print all_subjmat.shape
    return all_subjmat
示例#2
0
def reshape_netwise(data_scale):
    # Reshape with the following dim: nSubjects, nfeatures, nfeatures
    for i in range(0, data_scale.shape[0]):
        if i == 0:
            all_subjmat = ts.vec2mat(data_scale[i, :])[np.newaxis, ...]
        else:
            all_subjmat = np.vstack(
                (all_subjmat, ts.vec2mat(data_scale[i, :])[np.newaxis, ...]))

    #print all_subjmat.shape
    return all_subjmat
示例#3
0
def itStability(x,y,ind,k=1,samp_ratio=0.5,nsample=100):
    '''
    A random iterative resampling of the subject to compute the stability of the selected features
    '''
    subj_idx = range(0,x.shape[0])
    stability_hr_mat = np.zeros((len(ind),len(ind)))
    for i in range(0,nsample):
        sample_idx = np.random.permutation(subj_idx)[:np.int(len(subj_idx)*samp_ratio)]
        bestidx = getkBest(x[sample_idx,:],y[sample_idx],k)
        it_vote = np.zeros(x.shape[1])
        it_vote[bestidx] = 1 # create the vector of selected features
        lr_mat = ts.vec2mat(it_vote,include_diag=True) # convert to the low resolution matrix
        hr_mat = cls.projectmat(lr_mat,ind) # remap in HR
        # Add the matrix to the main HR stability matrix
        stability_hr_mat += hr_mat

    stability_hr_mat /= nsample
    return stability_hr_mat