Feature scaling


划重点:

  • Feature scaling思维导图
  • 什么是Data normalization和Feature scaling
  • 为什么要进行Feature scaling
  • Feature scaling的基本方法
Feature scaling思维导图

什么是normalization和feature scaling?

  数据标准化(Data normalization)就是通过消除量纲的操作,把数据限定在相同的范围内。最常见的数据标准化方法就是归一化,即把数据限定在(0,1)之间。
  特征缩放(feature scaling)属于数据标准化的范畴,Wiki解释:
  Feature scaling is a method used to standardize the range of independent variables or features of data. In data processing, it is also known as data normalization and is generally performed during the data preprocessing step.

为什么要进行feature scaling?

1. First Reason

  feature scaling能够消除每一维度特征对最后结果贡献的不平等性。可能有点绕口,来看两个例子。

1.1 First example:

  Since the range of values of raw data varies widely, in some machine learning algorithms, objective functions will not work properly without normalization. For example, the majority of classifiers calculate the distance between two points by the Euclidean distance(欧式距离). If one of the features has a broad range of values, the distance will be governed by this particular feature. Therefore, the range of all features should be normalized so that each feature contributes approximately proportionately to the final distance。(欧式距离最后结果由范围变化较大的特征支配)——from wiki

1.2 Second example:

实例

  我们通过三个特征(距离市中心的距离、楼层、面积)来预测房价。观察上图我们可知,面积的取值较大,很小的c值改动,就能引起房价很大的变化。——from blog

2. Second Reason

  Another reason why feature scaling is applied is that gradient descent converges much faster with feature scaling than without it。(梯度下降收敛的更快,观点来自2015的论文Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift,这篇论文以后会重点写一下)

Feature scaling的主要方法:

1. scaling

  最简单的方法是将特征的范围规范到(0,1)or(-1,1)。


image

2. Mean normalisation

image

3. Standardization

  在机器学习中,可以处理各种类型的数据,例如音频信号和图像数据的像素值,这些数据可以包括多个维度。特征标准化使各特征值的数据具有零均值(减去平均分子)和单位方差。在许多机器学习算法(如支持向量机、逻辑回归和神经网络)中,这种方法被广泛应用于标准化(Grus, Joel (2015). Data Science from Scratch)。这通常是通过计算标准分数来完成的。(Bin Mohamad, Ismail; Dauda Usman (2013))一般的计算方法是确定每个特征的分布均值和标准偏差。接下来,减去每个特征的平均值。然后,将得分除以标准偏差。


image

4. Scaling to unit length

  另一种广泛应用于机器学习的方法是对特征向量的分量进行缩放,使得完整的向量长度为1。这通常意味着将每个分量除以向量的欧几里得长度:


image

  在一些机器学习应用中,L1范数(欧氏距离)会有更好的效果。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 新场建镇约在南宋建炎二年(公元1128年),至今有800余年的历史,得名源于下沙盐场之南迁形成新的盐场,故...
    梅森meyssan阅读 5,667评论 1 8
  • 想来,赛前训练一月,只守就班,一成不变致有此败。 一味只去坚持这么去做,我就这么去做,没有料想环境如何积极适应,预...
    阗溢阅读 1,644评论 0 0
  • 在稻盛和夫看来,有激情地工作,认真地过好每一天非常的重要,严格约束自己,决不能浪费时间,把生命耗费在幻想和憧憬上。...
    f592aad0364c阅读 4,483评论 0 2
  • 先查询下他自动生成的二维码文件夹,是否生成了二维码。如果没有找到那个文件夹,说明没有自动生成二维码的文件夹,这个时...
    iiiiiiii1阅读 4,068评论 0 0