机器学习笔记-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 ...
随机推荐
- Jmeter正则提取list中相同key的value和出现的次数
list中如何计算某个key出现的次数以及通过正则关联参数化呢? 首先要通过正则提取出现key的value 举例:
- 一种抛弃GPS的中近距离高精度无线同步新方案
目前,对于需要做同步数据采集的项目,大家不约而同的选用GPS作同步源,用GPS的秒脉冲作同步基准.对于是1000米内的多采集点的应用来说,这是一种浪费. 目前福州慧聚通信技术有限公司推出一款无线同步数 ...
- (14)jdk1.5开始的一些新特性:静态导入,增强for循环,可变参数,自动装箱/拆箱,枚举类型
Jdk1.5新特性之静态导入 jdk1.5新特性值静态导入 静态导入的作用:简化缩写 静态导入的作用:可以作用一个类的所有静态成员. 静态导入的格式:import static 包名.类名.静态的成员 ...
- 解决SQLServer 2008 日志无法收缩,收缩后大小不改变
问题 数据库日志文件上G,或者几十G了,使用日志收缩,和日志截断收缩都不管用.体积一直减不下来.. 解决方案 查看日志信息 在查询分析器中执行如下代码来查看日志信息: DBCC LOGINFO('数 ...
- 学习CSS了解单位em和px的区别
这里引用的是Jorux的“95%的中国网站需要重写CSS”的文章,题目有点吓人,但是确实是现在国内网页制作方面的一些缺陷.我一直也搞不清楚px与em之间的关系和特点,看过以后确实收获很大.平时都是用p ...
- python3编码问题终结者--还搞不懂你来找我
python unicode bytes str 编码 首先需要说明一下,该篇文章是以python3为基础的,python2是否适合没有验证过.由于python编码问题确实比较多,文章篇幅可能较长,请 ...
- 环境搭建-VMware安装系统
常用的虚拟化软件: 1.vmware:收费 commercial(商业版的) 2.vitualbox:free 虚拟化软件:vmware workstation(虚拟系统工作站) 安装系统任务 ...
- Akamai在内容分发网络中的算法研究(翻译总结)
作者 | 钱坤 钱坤,腾讯后台开发工程师,从事领域为流媒体CDN相关,参与腾讯TVideo平台开发维护. 原文是<Algorithmic Nuggets in Content Delivery& ...
- js中prototype,__proto__,constructor之间的关系
首先,我们需要了解三点: 1. 只要创建一个任意新函数,就会根据一个prototype属性,该属性指向函数的原型对象: 2. 每一个原型对象都会自动获得一个constructor属性,该属性只想pro ...
- 生成 HTMLTestRunner 测试报告学习总结
HTMLTestRunner 的安装与使用 HTMLTestRunner 是 Python 标准库的 unittest 模块的一个扩展. 在使用之前,我们需要先安装他.下载地址:https://pyp ...