AI-005: 吴恩达教授(Andrew Ng)的机器学习课程学习笔记15-20

本文是学习Andrew Ng的机器学习系列教程的学习笔记。教学视频地址:

https://study.163.com/course/introduction.htm?courseId=1004570029#/courseDetail?tab=1

本文中的白色背景视频截图来自Andrew Ng的视频脚程, 思维导图为原创总结。

多变量的线性回归:

15. Linear Regression with multiple variables - multiple features
首先定义出线性回归的矩阵表示:
 

Use vector to show feature

Inner product(内积) is θ transpose X

Feature vector X

Parameter vector theta θ

Multivariate linear regression

16. Linear Regression with multiple variables - Gradient descent for multiple variables
然后是梯度下降的矩阵表示:


就是对各个特征求偏导,不包含求导参数时,导数都为0.
 

17. Linear Regression with multiple variables - Gradient descent in practice I : feature scaling
 

Feature scaling 特征

Y = θ1 * x1 + θ2 * x2

If x1 = 0-2000, x2 = 1-5, then when θ1 change a little, if want get a same Y you need change θ2 a lot.

Use feature scaling to get more effect Gradient Descent.

Feature scaling make x1 and x2 be closer. Then the gradient descent will converge much faster.

Dividing by the maximum value

18. Linear regression with multiple variables - gradient descent in practive II: learning rate
用图形化方法来查看选择的学习率参数合不合适,每次可以按3倍的关系调整学习率。这里要不断尝试,没有绝对方法。

J(θ) should decease after each iterations

After 400 iterations, the gradient descent is already converge.

Choosing what this threshold is pretty difficult.

So, in order to check your gradient descent has converged, I actually tend to look at plots like this figure. And this figure will tell you if your gradient descent is working correctly.

When you see this figure, thy to use small learning rate

Choose more α  to try.

Choose a small one and then increase the learning rate threefold.

Many times later, you will get one value that is too small and one value is too large.

Then I try to pick the largest possible value or just something slightly smaller than the largest reasonable value that I found. This may be a good learning rate for my problem.

19. Linear regression with multiple variables - features and polynomial regression 

How to choose features and algorithm

Polynomial regression allows you to use the machinery of linear regression to fit very complicated, even very non-linear functions.

Two features times together or add higher ^

Not use frontage and depth, but use land area = frontage * depth.

Feature scaling will more important when use polynomial regression

Choose different features you can sometimes get better models.

Find better models to fit your data.

20. Linear regression with multiple variables - normal equation
用公式来计算参数:

 

Normal equation can get the optimal value θ in basically one step.

Calculus tell us how to find better through take the partial derivative of J.

Normal equation:

And if you use normal equation there is no need to features scaling.

When number of features is large, use Gradient Descent.

When get non-invertibility X^TX, how to use normal equation.

When features have linear relations, the X^TX will be non-invertible.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

铭记北宸

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值