特征预处理:标准化
from sklearn.preprocessing import MinMaxScaler,StandardScaler
import pandas as pd
def stand_demo():
"""
特征欲处理:标准化
:return:
"""
# 1、获取数据
data = pd.read_csv("dating.txt")
data = data.iloc[:, :3]
# print("data:\n", data)
# 2、实例化一个转换器类
transfer = StandardScaler()
# 3、调用 fit_transform
data_new = transfer.fit_transform(data)
print("data_new:\n", data_new)
print("每一列特征的平均值:\n", transfer.mean_)
print("每一列特征的方差:\n", transfer.var_)
return None
if __name__ == '__main__':
stand_demo()