机器学习笔记-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 ...
随机推荐
- 百度推送-sitemap-使用playframework框架实现-java
主动推送的目的是能够把我们高质量内容推送给百度,但是首先你得有一个属于你自己的网站,在百度站长进行验证通过之后,才有资格推送百度sitemap. 百度站长平台为未使用百度统计的站点提供三种验证方式:文 ...
- Linux系统启动过程详解
启动第一步--加载BIOS当你打开计算机电源,计算机会首先加载BIOS信息,BIOS信息是如此的重要,以至于计算机必须在最开始就找到它.这是因为BIOS中包含了CPU的相关信息.设备启动顺序信息.硬盘 ...
- 降低Redis内存占用
1.降低redis内存占用的优点 1.有助于减少创建快照和加载快照所用的时间 2.提升载入AOF文件和重写AOF文件时的效率 3.缩短从服务器进行同步所需的时间 4.无需添加额外的硬件就可以让redi ...
- Android 7.0 调取系统相机崩溃解决android.os.FileUriExposedException
一.写在前面 最近由于廖子尧忙于自己公司的事情和OkGo(一款专注于让网络请求更简单的网络框架) ,故让LZ 接替维护ImagePicker(一款支持单.多选.旋转和裁剪的图片选择器),也是处理了诸多 ...
- nodejs 使用mongoose 操作mongodb
nodejs操作mongodb可以使用mongoose: Mongoose is a MongoDB object modeling tool designed to work in an async ...
- empty 语句
empty 语句: 用来表明没有语句, 尽管JavaScript语法希望有语句会被执行. empty语句 用分号表示 (;) ,用来指明没有语句会被执行, 尽管此时JavaScript语法需要执行语句 ...
- win32最简单的htmlayout图形界面demo
1,下载HTMLayoutSDK,放在workspace. SDK下载地址:http://www.terrainformatica.com/htmlayout/HTMLayoutSDK.zip 2,v ...
- vuejs子组件向父组件传递数据
子组件通过$emit方法向父组件发送数据,子组件在父组件的模板中,通过自定义事件接收到数据,并通过自定义函数操作数据 <!DOCTYPE html> <html lang=" ...
- PRINCE2重要性--光环国际培训
项目的重要性 答:对于当今的组织来说,一个关键的挑战,就是能够成功地平衡以下两个并存的.互相竞争的方面:保持现有的商业运营--盈利能力.服务质量.客户关系.品牌忠实度.生产效率.市场信心等,这些被称为 ...
- 【Electron】Electron开发入门(七):打开本地文件或者网页链接 and webview里操纵electron api
1.打开本地文件或者网页链接 // 打开系统本地文件 const {shell} = require('electron'); // Open a local file in the default ...