1. 标准化(Standardization or Mean Removal and Variance Scaling) 变换后各维特征有0均值,单位方差.也叫z-score规范化(零均值规范化).计算方式是将特征值减去均值,除以标准差. sklearn.preprocessing.scale(X) 一般会把train和test集放在一起做标准化,或者在train集上做标准化后,用同样的标准化器去标准化test集,此时可以用scaler scaler = sklearn.preprocessin…
RESCALING attribute data to values to scale the range in [0, 1] or [−1, 1] is useful for the optimization algorithms, such as gradient descent, that are used within machine learning algorithms that weight inputs (e.g. regression and neural networks).…
在上一篇博客中介绍了数值型数据的预处理但是真实世界的数据集通常都含有分类型变量(categorical value)的特征.当我们讨论分类型数据时,我们不区分其取值是否有序.比如T恤尺寸是有序的,因为XL>L>M.而T恤颜色是无序的.在讲解处理分类数据的技巧之前,我们先创建一个新的DataFrame对象: import pandas as pd from pandas import DataFrame data = {'color':['green','red','blue'], …