博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CS 229 notes Supervised Learning
阅读量:6603 次
发布时间:2019-06-24

本文共 867 字,大约阅读时间需要 2 分钟。

CS 229 notes Supervised Learning

标签(空格分隔): 监督学习 线性代数


Forword

the proof of Normal equation and, before that, some linear algebra equations, which will be used in the proof.

The normal equation

Linear algebra preparation

For two matrices A and B such that AB is square, trAB\ = \ trBA.

Proof:

 

 

Some properties:

 

some facts of matrix derivative:

\nabla_AtrAB=B^T...................................................................(1)

Proof:

 

\nabla_{A^T}f(A) = (\nabla_Af(A))^T...........................................................(2)

\nabla_AtrABA^TC = CAB+C^TAB^T..................................................(3)

Proof 1:

 

Proof 2:

 

\nabla_A|A| = |A|(A^{-1})^T.............................................................(4)

Proof: (\nabla_A |A|)_{pq} = C_{pq} = A^*_{qp} = (A^*)^T_{pq} = |A|(A^{-1})_{pq}

(C refers to the cofactor)

Least squares revisited

X = \begin{bmatrix}-(x^{(1)})^T-\\-(x^{(2)})^T-\\.\\.\\.\\-(x^{(m)})^T-\end{bmatrix}(if we don’t include the intercept term)

\vec y = \begin{bmatrix}y^{(1)}\\y^{(2)}\\.\\.\\.\\y^{(m)}\end{bmatrix}

since h_\theta(x^{(i)} = (x^{(i)})^T\theta,

Thus,

$\frac{1}{2}(X\theta-\vec{y})^T(X\theta-\vec{y}) =
\frac{1}{2}\displaystyle{\sum{i=1}^{m}(h\theta(x^{(i)}) -y^{(i)})^2} = J(\theta) $.

Combine Equations (2),(3)

\nabla_{A^T}trABA^TC = B^TA^TC^T+BA^TC..............................................(5)

Hence

\nabla_\theta J(\theta) = \frac{1}{2}\nabla_\theta(X\theta-\vec{y})^T(X\theta-\vec{y})\\  = \frac{1}{2}\nabla_\theta(\theta^TX^TX\theta-\theta^TX^T\vec{y}-\vec{y}X\theta -({\vec{y}})^T\vec{y})

Notice it is a real number, or you can see it as a 1\times 1 matrix, so

 

since trA = trA^T and \vec y involves no \theta elements.
then use equation (5) with A^T = \theta, B = B^T = X^TX, C = I

 

To minmize J, we set its derivative to zero, and obtain the normal equation:
X^TX\theta = X^T\vec{y}
\theta = (X^TX)^{-1}X^T\vec{y}

转载于:https://www.cnblogs.com/EtoDemerzel/p/7881434.html

你可能感兴趣的文章
javascript事件处理
查看>>
GridView導出Excel 解決亂碼問題
查看>>
ios规格证明
查看>>
ASP.NET下的JQ上传
查看>>
Linux安装mysql5.7
查看>>
openstack 制作镜像以及windows向Linux中通过xshell传文件
查看>>
和算法导论没什么关系0.手电筒过桥问题详解
查看>>
第二周学习
查看>>
3.25阅读摘抄
查看>>
LeeCode-Swap Nodes in Pairs
查看>>
JSR303结合切面校验参数
查看>>
130242014076+陈旭+第2次实验
查看>>
【MySQL】centOS中安装和配置MySQL
查看>>
bzoj 1070: [SCOI2007]修车
查看>>
乱码发生的原因
查看>>
CMD命令行基本命令
查看>>
Go语言的通道(2)-缓冲通道
查看>>
javascript 正则表达式邮箱验证
查看>>
poj1328
查看>>
response.write()跟ajax冲突的解决方案
查看>>