當前位置: 首頁>>代碼示例>>Python>>正文


Python StandardScaler.mean_方法代碼示例

本文整理匯總了Python中sklearn.preprocessing.StandardScaler.mean_方法的典型用法代碼示例。如果您正苦於以下問題:Python StandardScaler.mean_方法的具體用法?Python StandardScaler.mean_怎麽用?Python StandardScaler.mean_使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sklearn.preprocessing.StandardScaler的用法示例。


在下文中一共展示了StandardScaler.mean_方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: standard_scaler

# 需要導入模塊: from sklearn.preprocessing import StandardScaler [as 別名]
# 或者: from sklearn.preprocessing.StandardScaler import mean_ [as 別名]
 def standard_scaler(self):
     """Return a sklearn.preprocessing.StandardScaler"""
     s = StandardScaler()
     s.mean_ = self.mean()
     var = self.var()
     var[var <= 0] = 1  # ignore variables with zero variance
     s.std_ = np.sqrt(var)
     return s
開發者ID:Don86,項目名稱:microscopium,代碼行數:10,代碼來源:cluster.py

示例2: normalize

# 需要導入模塊: from sklearn.preprocessing import StandardScaler [as 別名]
# 或者: from sklearn.preprocessing.StandardScaler import mean_ [as 別名]
 def normalize(self, means=None, stds=None):
     """
     Normalize dataset either from its own statistical properties or from
     external one. In the second case, both means and stds must be provided.
     """
     scaler = StandardScaler()
     assert (means is None) == (stds is None)
     if means and stds:
         scaler.mean_ = np.array(means)
         scaler.std_ = np.array(stds)
     else:
         scaler.fit(self.data)
     self.data = scaler.transform(self.data, copy=False)
     return scaler.mean_.tolist(), scaler.std_.tolist()
開發者ID:Dencrash,項目名稱:seminar-knowledge-mining,代碼行數:16,代碼來源:dataset.py

示例3: train_test_split

# 需要導入模塊: from sklearn.preprocessing import StandardScaler [as 別名]
# 或者: from sklearn.preprocessing.StandardScaler import mean_ [as 別名]
from sklearn.cross_validation import train_test_split

X_train, X_test, y_train, y_test, w_train, w_test  = train_test_split(
    X, y, weights, test_size=0.25, random_state=0)

print("train data shape: %r, train target shape: %r, train weights shape: %r"
      % (X_train.shape, y_train.shape, w_train.shape))
print("test data shape: %r, test target shape: %r, test weights shape: %r"
      % (X_test.shape, y_test.shape, w_test.shape))

scaler = StandardScaler()
means = np.mean(X_train)
std = np.std(X_train)
print means[0]
scaler.mean_ = np.zeros(len(means))
scaler.std_ = np.ones(len(means))
for i in range(len(means)):
    scaler.mean_[i] = means[i]
    scaler.std_[i] = std[i]
print scaler.mean_
#scaler.mean_ = 
#X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)


print scaler.get_params(deep=True)
print scaler.mean_
print scaler.std_
sys.exit()
# Let's retrain a new model on the first subset call the **training set**:
開發者ID:tibristo,項目名稱:BosonTagger,代碼行數:32,代碼來源:tutorial.py


注:本文中的sklearn.preprocessing.StandardScaler.mean_方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。