import numpy as np
import pandas as pd
from pandas import Series,DataFrame
df = DataFrame({'height':np.random.randint(160,190,size = 50),
'weight':np.random.randint(45,90,size = 50),
'sex':np.random.randint(0,2,size = 50)})
df
df.max()

53.png
df.min()

37.png
df

24.png

57.png
# 消除不同属性之间的数量级差异,缩放,归一化(0~1)
df2 = (df - df.min(axis = 0))/(df.max() - df.min())
df2.describe()
45.png

15.png
# Z-score---->标准的高斯分布(正太分布)
# Z-score标准化方法,u 代表平均值
# δ表示std标准差
df3 = (df - df.mean())/df.std()
df3
# 平均值是0,标准差是1
49.png
df3.describe()

33.png
网友评论