Files
notes_estom/Sklearn/sklearn-cookbook-zh/test.py
2021-04-22 18:56:10 +08:00

20 lines
398 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#%% 加载数据
from sklearn import datasets
boston = datasets.load_boston()
X,y = boston.data,boston.target
X.shape
# %% 标准归一化
print(X[:,:3].mean(axis=0))
print(X[:,:3].std(axis=0))
from sklearn import preprocessing
my_scaler = preprocessing.StandardScaler()
my_scaler.fit(X[:,:3])
result = my_scaler.transform(X[:,:3])
# 值特别小近似为0
print(result[:,:3].mean(axis=0))