本文整理汇总了Python中sklearn.decomposition.PCA.mean方法的典型用法代码示例。如果您正苦于以下问题:Python PCA.mean方法的具体用法?Python PCA.mean怎么用?Python PCA.mean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.decomposition.PCA
的用法示例。
在下文中一共展示了PCA.mean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_randomized_pca_check_list
# 需要导入模块: from sklearn.decomposition import PCA [as 别名]
# 或者: from sklearn.decomposition.PCA import mean [as 别名]
def test_randomized_pca_check_list():
# Test that the projection by randomized PCA on list data is correct
X = [[1.0, 0.0], [0.0, 1.0]]
X_transformed = PCA(n_components=1, svd_solver="randomized", random_state=0).fit(X).transform(X)
assert_equal(X_transformed.shape, (2, 1))
assert_almost_equal(X_transformed.mean(), 0.00, 2)
assert_almost_equal(X_transformed.std(), 0.71, 2)
示例2: get_bold_signals
# 需要导入模块: from sklearn.decomposition import PCA [as 别名]
# 或者: from sklearn.decomposition.PCA import mean [as 别名]
def get_bold_signals (image, mask, TR,
normalize=True,
ts_extraction='mean',
filter_par=None,
roi_values=None):
'''
Image and mask must be in nibabel format
'''
mask_data = np.int_(mask.get_data())
if roi_values == None:
labels = np.unique(mask_data)[1:]
else:
labels = np.int_(roi_values)
final_data = []
#print labels
for v in labels[:]:
#print str(v)
data = image.get_data()[mask_data == v]
if normalize == True:
data = zscore(data, axis = 1)
data[np.isnan(data)] = 0
if ts_extraction=='mean':
#assert np.mean(data, axis=0) == data.mean(axis=0)
data = data.mean(axis=0)
elif ts_extraction=='pca':
if data.shape[0] > 0:
data = PCA(n_components=1).fit_transform(data.T)
data = np.squeeze(data)
else:
data = data.mean(axis=0)
ts = TimeSeries(data, sampling_interval=float(TR))
if filter_par != None:
upperf = filter_par['ub']
lowerf = filter_par['lb']
F = FilterAnalyzer(ts, ub=upperf, lb=lowerf)
ts = TimeSeries(F.fir.data, sampling_interval=float(TR))
del F
final_data.append(ts.data)
del data
del mask_data
del ts
return TimeSeries(np.vstack(final_data), sampling_interval=float(TR))