机器学习(西瓜书)之一元线性回归公式推导

一元线性回归公式推导

1.求解偏置b的公式推导思路:由最小二乘法导出损失函数 E ( ω , b ) E( \omega, b ) E(ω,b)—>证明损失函数 E ( ω , b ) E( \omega, b ) E(ω,b) 是关于 w w w b b b的凸函数—>对损失函数 E ( ω , b ) E( \omega, b) E(ω,b)关于 b b b求一阶偏导数—>令一阶偏导数等于 0 0 0解出 b b b

由最小二乘法导出损失函数 E ( ω , b ) E( \omega, b) E(ω,b):

E ( w , b ) = ∑ i = 1 m ( y i − f ( x i ) ) 2 = ∑ i = 1 m ( y i − ( ω x i + b ) ) 2 = ∑ i = 1 m ( y i − ω x i − b ) 2 ( p 54 . 3.4 ) E_{(w,b)}=\sum^{m}_{i = 1}(y_i-f(x_i))^2=\sum^{m}_{i = 1}(y_i-(\omega x_i+b))^2=\sum^{m}_{i = 1}(y_i-\omega x_i-b)^2 \tag{$ p_{54}.3.4$} E(w,b)=i=1m(yif(xi))2=i=1m(yi(ωxi+b))2=i=1m(yiωxib)2(p54.3.4)

证明损失函数 E ( ω , b ) E(\omega, b) E(ω,b)是关于 ω \omega ω b b b的凸函数—— 求: A = f x x 〞 ( x , y ) A=f_{xx}^{ 〞}(x,y) A=fxx(x,y)

∂ E ( w , b ) ∂ ω = ∂ ∂ ω [ ∑ i = 1 m ( y i − ω x i − b ) 2 ] = ∑ i = 1 m ∂ ∂ ω ( y i − ω x i − b ) 2 = ∑ i = 1 m 2 ⋅ ( y i − ω x i − b ) ⋅ ( − x i ) = 2 ( ω ∑ i = 1 m x i 2 − ∑ i = 1 m ( y i − b ) x i ) \frac{\partial E_{(w,b)}}{\partial \omega} =\frac{\partial }{\partial \omega} [\sum^{m}_{i = 1}(y_i-\omega x_i-b)^2] =\sum^{m}_{i = 1}\frac{\partial }{\partial \omega} (y_i-\omega x_i-b)^2 =\sum^{m}_{i = 1}2·(y_i-\omega x_i-b)·(-x_i) =2(\omega\sum^{m}_{i = 1}x_i ^2-\sum^{m}_{i = 1}(y_i-b)x_i) ωE(w,b)=ω[i=1m(yiωxib)2]=i=1mω(yiωxib)2=i=1m2(yiωxib)xi=2(ωi=1mxi2i=1m(yib)xi)上式即为即为(3.5)

A = f x x 〞 ( x , y ) = ∂ 2 E ( ω , b ) ∂ ω 2 = ∂ ∂ ω ( ∑ i = 1 m ∂ E ( w , b ) ∂ ω ) = ∂ ∂ ω [ 2 ( ω ∑ i = 1 m x i 2 − ∑ i = 1 m ( y i − b ) x i ) ] = ∂ ∂ ω [ 2 ω ∑ i = 1 m x i 2 ] = 2 ∑ i = 1 m x i 2 A=f_{xx}^{ 〞}(x,y)= \frac{\partial^2E_{(\omega,b)}}{\partial \omega^2} =\frac{\partial }{\partial \omega} (\sum^{m}_{i = 1}\frac{\partial E_{(w,b)}}{\partial \omega} ) =\frac{\partial }{\partial \omega}[2(\omega\sum^{m}_{i = 1}x_i ^2-\sum^{m}_{i = 1}(y_i-b)x_i)] =\frac{\partial }{\partial \omega}[2\omega\sum^{m}_{i = 1}x_i ^2] =2\sum^{m}_{i = 1}x_i ^2 A=fxx(x,y)=ω22E(ω,b)=ω(i=1mωE(w,b))=ω[2(ωi=1mxi2i=1m(yib)xi)]=ω[2ωi=1mxi2]=2i=1mxi2

求: B = f x y 〞 ( x , y ) B=f_{xy}^{ 〞}(x,y) B=fxy(x,y)

B = f x y 〞 ( x , y ) = ∂ 2 E ( ω , b ) ∂ ω ∂ b = ∂ ∂ b ( ∂ E ( w , b ) ∂ ω ) = ∂ ∂ b [ 2 ( ω ∑ i = 1 m x i 2 − ∑ i = 1 m ( y i − b ) x i ) ] = ∂ ∂ b [ − 2 ∑ i = 1 m ( y i − b ) x i ) ] = 2 ∑ i = 1 m x i B=f_{xy}^{ 〞}(x,y)= \frac{\partial^2E_{(\omega,b)}}{\partial \omega\partial b} =\frac{\partial }{\partial b} ( \frac{\partial E_{(w,b)}}{\partial \omega} ) =\frac{\partial }{\partial b} [2(\omega\sum^{m}_{i = 1}x_i ^2-\sum^{m}_{i = 1}(y_i-b)x_i)] =\frac{\partial }{\partial b}[-2\sum^{m}_{i = 1}(y_i-b)x_i)] =2\sum^{m}_{i = 1}x_i B=fxy(x,y)=ωb2E(ω,b)=b(ωE(w,b))=b[2(ωi=1mxi2i=1m(yib)xi)]=b[2i=1m(yib)xi)]=2i=1mxi

求: C = f y y 〞 ( x , y ) C=f_{yy}^{ 〞}(x,y) C=fyy(x,y)

∂ E ( w , b ) ∂ b = ∂ ∂ b [ ∑ i = 1 m ( y i − ω x i − b ) 2 ] = ∑ i = 1 m ∂ ∂ b ( y i − ω x i − b ) 2 = ∑ i = 1 m 2 ⋅ ( y i − ω x i − b ) ⋅ ( − 1 ) = 2 ( m b − ∑ i = 1 m ( y i − ω x i ) ) \frac{\partial E_{(w,b)}}{\partial b} = \frac{\partial }{\partial b}[\sum^{m}_{i = 1} (y_i-\omega x_i-b)^2] =\sum^{m}_{i = 1}\frac{\partial }{\partial b} (y_i-\omega x_i-b)^2 =\sum^{m}_{i = 1}2·(y_i-\omega x_i-b)·(-1) =2(mb-\sum^{m}_{i = 1}(y_i-\omega x_i)) bE(w,b)=b[i=1m(yiωxib)2]=i=1mb(yiωxib)2=i=1m2(yiωxib)1=2(mbi=1m(yiωxi))上式即为即为(3.6)

所以

机器学习(西瓜书)之一元线性回归公式推导_第1张图片

也即损失函数 E ( ω , b ) E(\omega, b) E(ω,b) 是关于 ω \omega ω b b b的凸函数得证
对损失函数 E ( ω , b ) E(\omega, b) E(ω,b) 关于b求一阶偏导数:机器学习(西瓜书)之一元线性回归公式推导_第2张图片
令一阶偏导数等于 0 解出b:机器学习(西瓜书)之一元线性回归公式推导_第3张图片

2.求解权重 ω , \omega, ω,的公式推导思路:对损失函数 E ( ω , b ) E( \omega, b) E(ω,b)关于 ω \omega ω求一阶偏导数—>令一阶偏导数等于 0 0 0解出 ω \omega ω

令一阶偏导数等于 0 解出 ω \omega ω机器学习(西瓜书)之一元线性回归公式推导_第4张图片

机器学习(西瓜书)之一元线性回归公式推导_第5张图片机器学习(西瓜书)之一元线性回归公式推导_第6张图片

3.将 ω \omega ω向量化:

机器学习(西瓜书)之一元线性回归公式推导_第7张图片机器学习(西瓜书)之一元线性回归公式推导_第8张图片机器学习(西瓜书)之一元线性回归公式推导_第9张图片

数学知识—二元函数判断凹凸性:机器学习(西瓜书)之一元线性回归公式推导_第10张图片

你可能感兴趣的:(深度之眼,机器学习)