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


Python StandardScaler.mean_[i]方法代碼示例

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


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

示例1: train_test_split

# 需要導入模塊: from sklearn.preprocessing import StandardScaler [as 別名]
# 或者: from sklearn.preprocessing.StandardScaler import mean_[i] [as 別名]
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**:

# In[15]:
from sklearn.ensemble import AdaBoostClassifier as ABC
開發者ID:tibristo,項目名稱:BosonTagger,代碼行數:33,代碼來源:tutorial.py


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