Machine Learning ---- Feature Scaling

本文介绍了特征缩放的概念,它为何在机器学习中重要,特别是通过AndrewNg的例子说明了数据范围对梯度下降法收敛速度的影响。文章详细讲解了标准化、均值标准化等方法及其适用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

 一、What is feature scaling::

二、Why do we need to perform feature scaling?

三、How to perform feature scaling:

        1、Normalization:

        2、Mean normalization:

        3、Standardization (data needs to follow a normal distribution):


 一、What is feature scaling:

        Simply put, it is the process of normalizing the units of data, which results in significant differences in the non unit values of various data in the training dataset. However, we use normalization and other methods to stabilize the data range within a relatively small area.

二、Why do we need to perform feature scaling?

        I have read many articles, and it's like how we often have a one-sided understanding of something due to its overly prominent side. For the more valuable side, we unconsciously lean towards the past. It is best for us to understand this point from a contour map:

        Using the example said by Andrew Ng, let's assume that his housing price prediction is:

Total square meter: 300 square meters~2000 square metersNumber of rooms: 1 to 5
w_1 = 50w_2 = 0.1
w_1 = 0.1w_2 = 50

        Meanwhile, assuming b=50, for a 2000 square meter, 5-room house, the normal price would be 500000 yuan:

        At the same time, assuming b=50, for a 2000 square meter, 5-room house, the normal price is 500000 yuan. Therefore, when we bring in two different groups of w1 and w2 in the list, we can find that the factor with the larger value is: the total square * 50+room * 0.1, which gives a value of about 100000 yuan, while the other group is about 500000 yuan.

        We can find that we prefer a smaller value with a larger corresponding coefficient. So, what is the relationship between this and gradient descent?

        We can understand it from the contour map:

        This is a contour map of J(\vec{w},b)  ,So we can take a look at how gradient descent may go if it needs to reach its minimum point:

        Due to the short axis range corresponding to size and the long axis corresponding to room, in order to obtain a minimum value that satisfies the condition through gradient descent, this situation may occur, leading to slower convergence. That's why we need to perform feature scaling, and if the image is not an ellipse but a circle, its effect is the best case.

        At the same time, we can also combine Euclidean distance for understanding

三、How to perform feature scaling:

        1、Normalization:

x^{'} = \frac{x - min(x)}{max(x) - min(x)}

        The corresponding value range is [0,1], but there are also more flexible forms:

x^{'} = a + \frac{x - min(x)}{max(x) - min(x)}(b - a)

        The corresponding value range is [a, b]. Generally speaking, the values of a and b should not be too large or too small, and [-5, 5] are suitable.

        2、Mean normalization:

x^{'} = \frac{x - \bar{x}}{max(x) - min(x)}

        3、Standardization (data needs to follow a normal distribution):

x^{'} = \frac{x - \bar{x}}{\sigma }

        The denominator corresponds to the standard deviation of x, which is actually the standardized formula for a normal distribution:

x^{'} = \frac{x - \mu}{\sigma }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值