机器学习笔记-1 Linear Regression with Multiple Variables(week 2)
1. Multiple Features

note:X0 is equal to 1
2. Feature Scaling
Idea: make sure features are on a similiar scale, approximately a -1<Xi<1 range
For example:
x1 = size (0-2000 feet^2) max-min or standard deviation
x2 = number of bedrooms(1-5)
The contour function of theta1 and theat2 is a very skewed elliptical shape. And
if you are running gradient descent on this, your gradients may end up a long time
to fjnd the global minimum.
Cure:
x1 = size (0-5000 feet^2)/2000
x2 = number of bedrooms(1-5)/5
so the coutour plots will give a much more direct path to the minimum
Mean normalization:
Replace Xi with Xi - Ui to make features have zero mean(except X0)
Eg:
X1 = (size-1000)/2000
X2= (#bedrooms-2)/5
3. Learning Rate
We can plot the J(theata) vs number of iterations and the J(theata) should
decrease after every iteraion. and we can also see if the gradient descent converges or not.
And if gradient descent is not working, usually means that:
you should use a smaller value of alpha(learning rate)
To choose alpha():
..., 0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1...
4. Features
you can try to define new features, for example:
Area = frontage * depth
Polynomial regression:
we can set that x1=size, x2=(size)^2, x3=(size)^3(remember ot feature scaling)
and it becomes linear regression
5. Normal Equations
Idea: method to solve for theta analytically

where x is m*(n-1) dimensional matrix and y is a m dimensional matrix,
n : number of features, m:number of training example
And feature scaling is not necessary for normal equations
Gradient descent
1. choose alpha
2. need many iterations
3. works well even have large number of features n.
Normal equation:
1. no need for alpha and iterations
2. need to compute matrix inverse
3. slow for large n (n = 10^6 etc)
Note
is not invertible means that:
1. you have got redundant features(linearly dependent)
2. there are too many features, delete some features, or use regularization

机器学习笔记-1 Linear Regression with Multiple Variables(week 2)的更多相关文章
- 机器学习 (二) 多变量线性回归 Linear Regression with Multiple Variables
文章内容均来自斯坦福大学的Andrew Ng教授讲解的Machine Learning课程,本文是针对该课程的个人学习笔记,如有疏漏,请以原课程所讲述内容为准.感谢博主Rachel Zhang 的个人 ...
- 机器学习(三)--------多变量线性回归(Linear Regression with Multiple Variables)
机器学习(三)--------多变量线性回归(Linear Regression with Multiple Variables) 同样是预测房价问题 如果有多个特征值 那么这种情况下 假设h表示 ...
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 4_Linear Regression with Multiple Variables 多变量线性回归
Lecture 4 Linear Regression with Multiple Variables 多变量线性回归 4.1 多维特征 Multiple Features4.2 多变量梯度下降 Gr ...
- 【原】Coursera—Andrew Ng机器学习—Week 2 习题—Linear Regression with Multiple Variables 多变量线性回归
Gradient Descent for Multiple Variables [1]多变量线性模型 代价函数 Answer:AB [2]Feature Scaling 特征缩放 Answer:D ...
- Machine Learning – 第2周(Linear Regression with Multiple Variables、Octave/Matlab Tutorial)
Machine Learning – Coursera Octave for Microsoft Windows GNU Octave官网 GNU Octave帮助文档 (有900页的pdf版本) O ...
- Linear regression with multiple variables(多特征的线型回归)算法实例_梯度下降解法(Gradient DesentMulti)以及正规方程解法(Normal Equation)
,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, , ...
- 斯坦福机器学习视频笔记 Week2 多元线性回归 Linear Regression with Multiple Variables
相比于week1中讨论的单变量的线性回归,多元线性回归更具有一般性,应用范围也更大,更贴近实际. Multiple Features 上面就是接上次的例子,将房价预测问题进行扩充,添加多个特征(fea ...
- 机器学习之多变量线性回归(Linear Regression with multiple variables)
1. Multiple features(多维特征) 在机器学习之单变量线性回归(Linear Regression with One Variable)我们提到过的线性回归中,我们只有一个单一特征量 ...
- 机器学习笔记1——Linear Regression with One Variable
Linear Regression with One Variable Model Representation Recall that in *regression problems*, we ar ...
随机推荐
- python 机器学习 决策树
决策树(Decision Trees ,DTs)是一种无监督的学习方法,用于分类和回归. 优点:计算复杂度不高,输出结果易于理解,对中间值缺失不敏感,可以处理不相关的特征数据缺点:可能会产生过度匹配的 ...
- 一步到位分布式开发Zookeeper实现集群管理
说到分布式开发Zookeeper是必须了解和掌握的,分布式消息服务kafka .hbase 到hadoop等分布式大数据处理都会用到Zookeeper,所以在此将Zookeeper作为基础来讲解. Z ...
- 混合拉普拉斯分布(LMM)推导及实现
作者:桂. 时间:2017-03-21 07:25:17 链接:http://www.cnblogs.com/xingshansi/p/6592599.html 声明:欢迎被转载,不过记得注明出处哦 ...
- X64系统下IIS运行ASP网站HTTP500错误 【安装FoxMail Server时出现】
错误如上 解决办法 使用管理员模式运行CMD 输入cscript C:\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitA ...
- wireshark过滤规则
WireShark过滤语法 1.过 滤IP,如来源IP或者目标IP等于某个IP 例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.ad ...
- Visual Studio 2017 新特性
全新的安装体检 VS2017更好的支持了按需安装的特点,用户可以仅选择需要的功能安装,节省了不少的Disk 最小的安装仅有几百兆,但也支持20多种编程语言的编辑和源码管理 支持创建自定义的离线安装包 ...
- php多进程编程详解
php多进程编程 前言 php单进程存在的问题: 多核处理器未充分利用,而单处理器通常需要等待其他操作完成之后才能再继续工作. 任何现代操作系统都可在幕后执行多任务,这意味着在很短时间内,计算机可以调 ...
- php人员权限管理(RBAC)
在说权限管理前,应该先知道权限管理要有哪些功能: (1).用户只能访问,指定的控制器,指定的方法 (2).用户可以存在于多个用户组里 (3).用户组可以选择,指定的控制器,指定的方法 (4).可以添 ...
- iOS开发之Quartz2D
1. Quartz2D概述及作用 Quartz2D的API是纯C语言的,Quartz2D的API来自于Core Graphics框架. 数据类型和函数基本都以CG作为前缀,比如: CG ...
- TCP的三次握手(建立连接)与 四次挥手(关闭连接)
一.TCP报文格式 TCP/IP协议的详细信息参看<TCP/IP协议详解>三卷本.下面是TCP报文格式图: TCP报文格式上图中有几个字段需要重点介绍下: (1)序号:Seq序号,占32位 ...