本文整理匯總了Python中sklearn.preprocessing.StandardScaler.flatten方法的典型用法代碼示例。如果您正苦於以下問題:Python StandardScaler.flatten方法的具體用法?Python StandardScaler.flatten怎麽用?Python StandardScaler.flatten使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.preprocessing.StandardScaler
的用法示例。
在下文中一共展示了StandardScaler.flatten方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: StandardScaler
# 需要導入模塊: from sklearn.preprocessing import StandardScaler [as 別名]
# 或者: from sklearn.preprocessing.StandardScaler import flatten [as 別名]
normalizeFeatures = 'Mean'
if normalizeFeatures == 'MeanAndStd':
X_std = StandardScaler().fit_transform(vecPosMatrix)
elif normalizeFeatures == 'Mean':
X_std = vecPosMatrix - np.mean(vecPosMatrix,0)
print "Making sklearn_pca"
nComponents = 10
sklearn_pca = sklearnPCA(n_components=nComponents)
print "Making Y_sklearn"
# An important note -- we get a hash value for the raw data here
# as a unique identifier of this dataset. Then we save the initial
# PCA object to disk to reduce time on subsequent runs.
sklearn_pca_hash = str(hash(tuple(X_std.flatten()[::100])))[-10:]
#pca_result_hash = 'y_sklearn_hash_%s.cpickle' %(sklearn_pca_hash)
pca_result_hash = 'pca_obj_hash_%s.cpickle' %(sklearn_pca_hash)
if not(os.path.exists(pca_result_hash)):
#Y_sklearn = sklearn_pca.fit_transform(X_std)
sklearn_pca.fit(X_std)
with open(pca_result_hash,'wb') as of:
cPickle.dump(sklearn_pca, of)
Y_sklearn = sklearn_pca.transform(X_std)
#with open(pca_result_hash,'wb') as of:
# cPickle.dump(Y_sklearn, of)
else:
#Y_sklearn = cPickle.load(open(pca_result_hash))
sklearn_pca = cPickle.load(open(pca_result_hash))
Y_sklearn = sklearn_pca.transform(X_std)