Normal Equation

Gradient descent gives one way of minimizing J. Let’s discuss a second way of doing so, this time performing the minimization explicitly and without resorting to an iterative algorithm. In the “Normal Equation” method, we will minimize J by explicitly taking its derivatives with respect to the θj ’s, and setting them to zero. This allows us to find the optimum theta without iteration. The normal equation formula is given below:
θ=(XTX)−1XTyθ=(XTX)−1XTyθ=(X^TX)^{−1}X^Ty

There is no need to do feature scaling with the normal equation.
The following is a comparison of gradient descent and the normal equation:

Gradient Descent Normal Equation
Need to choose alpha No need to choose alpha
Needs many iterations No need to iterate
O(kn2)O(kn2)\mathcal{O}(kn^2) O(kn3)O(kn3)\mathcal{O}(kn^3),need to calculate inverse of XTXXTXX^TX
Works well when n is large Slow if n is very large

With the normal equation, computing the inversion has complexity O(n3)O(n3)\mathcal{O}(n^3). So if we have a very large number of features, the normal equation will be slow. In practice, when n exceeds 10,000 it might be a good time to go from a normal solution to an iterative process.

Normal Equation Noninvertibility

When implementing the normal equation in octave we want to use the ‘pinv’ function rather than ‘inv.’ The ‘pinv’ function will give you a value of θθ\theta even if XTXXTXX^TX is not invertible.
If XTXXTXX^TX is noninvertible, the common causes might be having :
- Redundant features, where two features are very closely related (i.e. they are linearly dependent)
- Too many features (e.g. m ≤ n). In this case, delete some features or use “regularization” (to be explained in a later lesson)
Solutions to the above problems include deleting a feature that is linearly dependent with another or deleting one or more features when there are too many features.

【Machine Learning】【Andrew Ng】- notes(Week 2: Computing Parameters Analytically)相关推荐

  1. Machine Learning课程 by Andrew Ng

    大名鼎鼎的机器学习大牛Andrew Ng的Machine Learning课程,在此mark一下: 一:Coursera: https://www.coursera.org/learn/machine ...

  2. Machine learning week 10(Andrew Ng)

    文章目录 Reinforcement learning 1. Reinforcement learning introduction 1.1. What is Reinforcement Learni ...

  3. Machine Learning Outline(Andrew Ng课程总结)

  4. 【Machine Learning】OpenCV中的K-means聚类

    在上一篇([Machine Learning]K-means算法及优化)中,我们介绍了K-means算法的基本原理及其优化的方向.opencv中也提供了K-means算法的接口,这里主要介绍一下如何在 ...

  5. 【原】Coursera—Andrew Ng机器学习—Week 9 习题—异常检测

    [原]Coursera-Andrew Ng机器学习-Week 9 习题-异常检测 参考文章: (1)[原]Coursera-Andrew Ng机器学习-Week 9 习题-异常检测 (2)https: ...

  6. 【Machine Learning 学习笔记】Stochastic Dual Coordinate Ascent for SVM 代码实现

    [Machine Learning 学习笔记]Stochastic Dual Coordinate Ascent for SVM 代码实现 通过本篇博客记录一下Stochastic Dual Coor ...

  7. 【Machine Learning 学习笔记】feature engineering中noisy feature的影响

    [Machine Learning 学习笔记]feature engineering中noisy feature的影响 通过本篇博客记录一下添加噪声对Lasso和SVM的影响,采用的数据集为sklea ...

  8. Andrew Ng Machine Learning 专题【Logistic Regression amp; Regularization】

    此文是斯坦福大学,机器学习界 superstar - Andrew Ng 所开设的 Coursera 课程:Machine Learning 的课程笔记. 力求简洁,仅代表本人观点,不足之处希望大家探 ...

  9. 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 17—Large Scale Machine Learning 大规模机器学习...

    Lecture17 Large Scale Machine Learning大规模机器学习 17.1 大型数据集的学习 Learning With Large Datasets 如果有一个低方差的模型 ...

最新文章

  1. 搞机器学习的人,必须要知道的大牛都有谁?
  2. angular指令:tm.tags添加/删除标签
  3. 软工随堂练 找出和值最小的子数组 尹亚男 赵静娜
  4. matlab如何响两声,matlab发出声音
  5. python图像处理专业博客
  6. docker harbor 域名_超详细的搭建docker私服Harbor教程
  7. require(),include(),require_once()和include_once()区别
  8. 【汇编语言】王爽实验5(5)(6)的解答 建立数据类型匹配的观念
  9. oracle data guard闪回,11gR2 Active Data Guard 闪回 - flashback database / snapshot standby - 2
  10. java-第十章-类和对象-创建管理员对象
  11. SAP License:职业生涯与发展之路——写给李婷小妹妹的信
  12. 10 个优秀的JavaScript开发框架
  13. linux 与win共享文件夹
  14. Java---类反射(1)---类反射入门和基础
  15. CountDownLatch分析(AQS共享锁)
  16. 禁用电子邮件服务器,启用或禁用对邮箱中的邮箱的 POP3 或 IMAP4 Exchange Server
  17. MySQLIntegrityConstraintViolationException异常处理
  18. python的语言是开源的_python语音识别 开源_DaCiDian是一个开源的中文普通话词汇,用于自动语音识别(ASR)....
  19. linux无法解析域名
  20. java后端实现集成支付宝APP支付(沙箱环境)

热门文章

  1. http://www.atool.org/keytype.php#0-tsina-1-53371-397232819ff9a47a7b7e80a40613cfe1
  2. 美洽消息推送 php,GitHub - Meiqia/MeiqiaSDK-Push-Signature-Example: 美洽 SDK 3.0 推送的数据结构签名算法,多语言示例。...
  3. cad面积累计lisp怎么用_求一个cad的lisp:一次计算多个封闭线框的面积,并显示每个面积和总面积...
  4. android 3d轮播图,3D轮播图
  5. Cas(03)——Cas Server中各配置文件介绍
  6. Linear Programming线性规划(Introduction to Algorithms, 算法导论,CLRS)学习笔记
  7. APP上架 苹果应用商店AppStore 需准备素材
  8. SVM模型训练和调参
  9. gdkoi2016爆零记
  10. Nginx rewrite 和 proxy_pass共用