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 Xwith 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)的更多相关文章

  1. 机器学习 (二) 多变量线性回归 Linear Regression with Multiple Variables

    文章内容均来自斯坦福大学的Andrew Ng教授讲解的Machine Learning课程,本文是针对该课程的个人学习笔记,如有疏漏,请以原课程所讲述内容为准.感谢博主Rachel Zhang 的个人 ...

  2. 机器学习(三)--------多变量线性回归(Linear Regression with Multiple Variables)

    机器学习(三)--------多变量线性回归(Linear Regression with Multiple Variables) 同样是预测房价问题  如果有多个特征值 那么这种情况下  假设h表示 ...

  3. 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 4_Linear Regression with Multiple Variables 多变量线性回归

    Lecture 4 Linear Regression with Multiple Variables 多变量线性回归 4.1 多维特征 Multiple Features4.2 多变量梯度下降 Gr ...

  4. 【原】Coursera—Andrew Ng机器学习—Week 2 习题—Linear Regression with Multiple Variables 多变量线性回归

    Gradient Descent for Multiple Variables [1]多变量线性模型  代价函数 Answer:AB [2]Feature Scaling 特征缩放 Answer:D ...

  5. 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 ...

  6. Linear regression with multiple variables(多特征的线型回归)算法实例_梯度下降解法(Gradient DesentMulti)以及正规方程解法(Normal Equation)

    ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, , ...

  7. 斯坦福机器学习视频笔记 Week2 多元线性回归 Linear Regression with Multiple Variables

    相比于week1中讨论的单变量的线性回归,多元线性回归更具有一般性,应用范围也更大,更贴近实际. Multiple Features 上面就是接上次的例子,将房价预测问题进行扩充,添加多个特征(fea ...

  8. 机器学习之多变量线性回归(Linear Regression with multiple variables)

    1. Multiple features(多维特征) 在机器学习之单变量线性回归(Linear Regression with One Variable)我们提到过的线性回归中,我们只有一个单一特征量 ...

  9. 机器学习笔记1——Linear Regression with One Variable

    Linear Regression with One Variable Model Representation Recall that in *regression problems*, we ar ...

随机推荐

  1. TIME_WAIT问题总结

         最近用http_load做压测,跑出来一大串"Cannot assign requested address "的错误,查了一下,是TIME_WAIT过多导致的.因为短时 ...

  2. Java引领新生活

    阅读邹欣老师的博客,谈谈你期望的师生关系是什么样的? 我觉得师生关系应当是亲密无间,课上老师讲解学生配合,课下师生交流启发思考. 你有什么技能(学习,棋类,球类,乐器,艺术,游戏,......)比大多 ...

  3. 适用MySQL Migration Toolkit 1.0 将oracle迁移到mysql中遇到的问题

    这里主要说一下我在适用中碰到的问题,主要过程参考 http://www.cnblogs.com/duwenlei/p/3520759.html. 首先启动MySQLMigrationTool.exe ...

  4. python生成二维码

    1.python-qrcode是个用来生成二维码图片的第三方模块,依赖于 PIL 模块和 qrcode 库. 首先,我们要安装三个模块,qrcode,image,PIL. pip install  q ...

  5. Node.js 基础介绍

    什么是Node.js 官网介绍: Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js us ...

  6. 实验楼-2-Linux基础快捷键

    终端:本质上对应着Linux上的/dev/tty设备 shell:打开终端,shell则自动打开 可以在终端直接输入: echo "hello world" /*shell程序自动 ...

  7. TCP的三次握手(建立连接)与 四次挥手(关闭连接)

    一.TCP报文格式 TCP/IP协议的详细信息参看<TCP/IP协议详解>三卷本.下面是TCP报文格式图: TCP报文格式上图中有几个字段需要重点介绍下: (1)序号:Seq序号,占32位 ...

  8. spring+mybatis之声明式事务管理初识(小实例)

    前几篇的文章都只是初步学习spring和mybatis框架,所写的实例也都非常简单,所进行的数据访问控制也都很简单,没有加入事务管理.这篇文章将初步接触事务管理. 1.事务管理 理解事务管理之前,先通 ...

  9. require.js 源码解读——配置默认上下文

    首先,我们先来简单说一下,require.js的原理: 1.载入模块
 2.通过模块名解析出模块信息,以及计算出URL
 3.通过创建SCRIPT的形式把模块加载到页面中.
 4.判断被加载的脚本,如 ...

  10. pg_config executable not found

    Error: pg_config executable not found. Please add the directory containing pg_config to the PATH or ...