特征缩放

Feature Scalling

Idea: Make sure features are on a similar scale

特征缩放

想法:确保所有的特征在相似的范围


为什么进行特征缩放?

例如:x1 = size (0-2000 feet2)

        x2 = number of bedrooms (1-5)

x1和x2范围相差很大

算法需要很长时间才能到达最小值

如果把x1和x2做如下处理

\[{x_1} = \frac{{{x_1}}}{{2000}}\]

\[{x_2} = \frac{{{x_2}}}{5}\]

x1和x2的范围会变为[0, 1]

则图形会变为如下所示

这样做可以让算法收敛更快

其实,特征的范围不一定要在一个范围内,相差不多就可以


Mean normalization

Replace xi with xi-ui to make features have approximately zero mean (Do not apply to x0 = 1)

替换xi为xi-ui,使特征具有近似零均值

一般情况下使用如下公式 \[{x_i} = \frac{{{x_i} - {\nu _i}}}{{{x_{i\_\max }} - {x_{i\_\min }}}}\]

 

posted @ 2018-10-22 21:45  qkloveslife  阅读(829)  评论(0编辑  收藏  举报