Exemplo n.º 1
0
Arquivo: test.py Projeto: FF120/python
plt.title('Variance of Voxel')
#plt.grid(True)
#plt.xlim()
#plt.ylim(varmin,varmax)
xx = np.linspace(1, XX_show.shape[1], XX_show.shape[1])
plt.plot(xx, var, 'r')

plt.subplot(212)
plt.plot(xx, mean, 'b')
plt.show()

#===================移除所有方差很低的特征=================================
from sklearn.feature_selection import VarianceThreshold
sel = VarianceThreshold(threshold=2000)
X2 = sel.fit_transform(X)
support_mask = sel._get_support_mask()
#mask_img = X[1,:]
mask_img = support_mask.astype('float64')
#for i in xrange(support_mask.shape[0]):
#    if not support_mask[i]:
#        mask_img[i] = 0

coef_img = nifti_masker.inverse_transform(mask_img)
coef_img.to_filename(r'D:\aaa.img')

#==================单变量特征选择方法===========================
from sklearn.feature_selection import SelectPercentile, f_classif
XX1 = X
yy1 = fm.defineClass(y)
'''数据标准化'''
#from sklearn import preprocessing
Exemplo n.º 2
0
Arquivo: test.py Projeto: FF120/python
plt.title('Variance of Voxel')
#plt.grid(True)
#plt.xlim()
#plt.ylim(varmin,varmax)
xx = np.linspace(1,XX_show.shape[1],XX_show.shape[1])
plt.plot(xx,var,'r') 

plt.subplot(212)
plt.plot(xx,mean,'b')
plt.show()

#===================移除所有方差很低的特征=================================
from sklearn.feature_selection import VarianceThreshold
sel = VarianceThreshold(threshold=2000)
X2 = sel.fit_transform(X)
support_mask = sel._get_support_mask()
#mask_img = X[1,:]
mask_img = support_mask.astype('float64')
#for i in xrange(support_mask.shape[0]):
#    if not support_mask[i]:
#        mask_img[i] = 0
        
coef_img = nifti_masker.inverse_transform(mask_img)
coef_img.to_filename(r'D:\aaa.img')

#==================单变量特征选择方法===========================
from sklearn.feature_selection import SelectPercentile, f_classif
XX1 = X
yy1 = fm.defineClass(y)
'''数据标准化'''
#from sklearn import preprocessing