import pandas as pd import numpy as np from sklearn import preprocessing,linear_model,metrics data = pd.DataFrame({'pet': ['cat', 'dog', 'dog', 'fish', 'cat', 'dog', 'cat', 'fish'], 'children': [4., 6, 3, 3, 2, 3, 5, 4], 'salary': [90, 24, 44, 27, 32, 59, 36, 27]}) lb = preprocessing.LabelBinarizer() #标签二值化(Label binarization) #LabelBinarizer通常用于通过一个多类标签(label)列表,创建一个label指示器矩阵 pdlb=pd.DataFrame(lb.fit_transform(data['pet']),columns=['cat','dog','fish']) #横向合并 data=pd.concat([data,pdlb],axis=1) #数据标准化(Standardization or Mean Removal and Variance Scaling) #scale进行标准化缩放的数据均值为0,具有单位方差。 data['children']=preprocessing.scale(data['children']) #数据规范化(Norm...