Machine Learning ---- Multiple linear regression equation

本文介绍了多变量线性回归的基本概念,探讨了如何将其扩展到多个影响因素的情况,重点讲解了向量化处理在Python库Numpy中的应用以及使用梯度下降进行参数估计的过程。

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

一、Multiple linear regression:

        In the study of real-world problems, the changes in the dependent variable are often influenced by several important factors. In this case, it is necessary to use two or more influencing factors as independent variables to explain the changes in the dependent variable. This is known as multiple regression, also known as multiple regression. When there is a linear relationship between multiple independent variables and the dependent variable, the regression analysis conducted is called multiple linear regression.

        Let's first review its univariate linear regression equation:

 f(x_i) = wx_i + b

        So, for its multiple linear regression equation, we only need to transform w and x in it:

f_{\vec{w},b}(\vec{x}) = \vec{w}_i\vec{x}_i + b

        each of \vec{w}_i and \vec{x}_iis a set of vectors,b is a number。

二、Deeply understand:

        within this function,\vec{x}_i = [x_1,x_2.....x_i] , \vec{w}_i = [w_1,w_2.....w_i] ,the standard expansion formula is:

f_{\vec{w},b}(\vec{x}) = \vec{w}_1\vec{x}_1 + \vec{w}_2\vec{x}_2 + \vec{w}_3\vec{x}_3 + ...... + \vec{w}_i\vec{x}_i + b

        That is, the impact of number of i factors on the variable:

        We observe x_i through a table

x_1x_2x_3f(w,b)
1231331222
1623673215

        Each row corresponds to x is a dataset, and each column represents the corresponding influencing factors.

三、Vectorization processing:

       For this function:

f_{\vec{w},b}(\vec{x}) = \vec{w}_1\vec{x}_1 + \vec{w}_2\vec{x}_2 + \vec{w}_3\vec{x}_3 + ...... + \vec{w}_i\vec{x}_i + b

       We transformed it into

f_{\vec{w},b}(\vec{x}) = \vec{w}_i\vec{x}_i + b

     So in the program, what kind of implementation do we use and what are the differences?

    Firstly, when n is not large, we can traverse:

w = np.array([1.0,2.5,-3,3])
b = 4
x = np.array([10,20,30])

f = w[0]*b[0] + w[1]*b[1] + w[2]*b[2] + b

        Then, using the for loop method

f = 0
for j in range(0,n):
    f = f + w[j] * x[j]
f = f + b

        Finally, we can use the Numpy library:

f = np.dot(w,x) + b

       Among the above three methods, it is particularly recommended to use the last one, as the Numpy function can utilize hardware parallel operations. When n is large, the difference in computation speed is particularly significant.

四、Gradient descent in multiple linear regression:

        The gradient descent operation in multiple linear regression is:

        repeat_(

w_1 = w_1 - \alpha \frac{ \partial j(w_1,b) }{ \partial w }

w_2 = w_2 - \alpha \frac{ \partial j(w_2,b) }{ \partial w }

..........

b = b - \alpha \frac{ \partial J(w,b) }{ \partial b }

        )

        If the J (w, b) function is introduced, each expression of w is equal to:

w_i = w_i - a\frac{1}{m}\sum_{j = 1}^{m} f_{\vec{w},b}(x^{(i)} - y^{(i)}) * x^{(i)}

       Its points of attention and understanding are the same as Univariate linear regression equation。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值