机器学习笔记-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 ...
随机推荐
- CSS 去掉点li 的点
转:http://blog.sina.com.cn/s/blog_63b13c300100jyek.html 方法一: <ul> <li style="list-style ...
- docker工作流程
Docker提供一种方法在容器中运行安全隔离的应用程序,应用程序与所有依赖项和库一起打包在容器中.因为你的应用程序总是可以使用它在构建镜像中期望的环境运行,测试和部署比以往任何时候都更简单,因为你的构 ...
- iOS开发之@Selector参数的传递
比如: NSMutableDictionary *dic = [[NUMutableDictionary alloc]init]; [dic setValue:@”haha” forKey:@”tes ...
- Linux网络设备驱动(一) _驱动模型
Linux素来以其强大的网络功能著名,同时, 网络设备也作为三大设备之一, 成为Linux驱动学习中必不可少的设备类型, 此外, 由于历史原因, Linux并没有强制对网络设备贯彻其"一切皆 ...
- 【C语言】判断三角形类型
根据输入的三角形的三边判断三角形的类型,并输出其面积和类型. #include<stdio.h> #include<stdlib.h> #include<math.h&g ...
- python之pymysql模块学习(待完善...)
pymysql介绍 pymysql是在python3.x版本中用于连接mysql服务器的一个库.python2中则使用mysqldb. 安装方法: pip install pymysql 使用实例: ...
- PyQt通过resize改变窗体大小时ListWidget显示异常
前几天开始的pygame音乐播放器Doco,做的差不多了,上午做到了歌词显示和搜索页面.遇到bug,即通过resize改变ui大小时ListWidget显示异常 #目的: 增加一部分窗口用来显示歌词和 ...
- Git基本操作命令2
git本地仓库同步到远程仓库上 $ git remote add origin http://github.com/powfulCsharp/NuUserControl.git $ git push ...
- JSP/Servlet------------------------->>动态网页开发基础(一)
动态网页:是指在服务器端运行的,使用程序语言设计的交互式网页,它们会根据某种条件的变化,返回不同的网页内容. 动态网站可以实现交互功能,如用户注册.信息发布.产品展示.订单管理等等: 动态网页并不是独 ...
- 跟着刚哥梳理java知识点——运算符(五)
运算符:是一种特殊的符号,用以表示数据的运算.赋值和比较. 1.算数运算符(+.-.*./.%.++.--) a)除: int i = 12; double d1 = i / 5; //2.0 dou ...