1、Multiple features

  • So what the form of the hypothesis should be ?

  • For convenience, define x0=1

  • At this time, the parameter in the model is a ( + 1)-dimensional vector, and any training instance is also a ( + 1)-dimensional vector. The dimension of the feature matrix is { ∗ ( + 1)} , so the formula can be simplified to :

2、Gradient descent for multiple variables

  • Here is the gradient descent looks like

  • Python code:
def computeCost(X, y, theta):
inner = np.power(((X * theta.T) - y), 2)
return np.sum(inner) / (2 * len(X)

3、Gradient descent in practice I :Feature Scaling

  • An idea about feature scaling(特征缩放) --- make sure features are on a similar scale and get every feature into approximately a -1≤xi≤1 range

4、Gradient descent in practice II: Learning rate

5、Features and Polynomial Regression

  • Housing price prediction

  • Linear regression is not suitable for all data, sometimes we need a curve to fit our data, such as a quadratic model :

  • Or maybe a cubic model :

  • According to the graphical characteristics of the function, we can also use :

6、Normal Equation

  • Normal equation : method to solve for θ analytically
  • It is too long and involved
  • And now,I am going to take the dataset and add an extra column
  • Then construct a matrix X :

  • And construct a vector y :

  • Solve the vector using the normal equation :

  • We get :

pinv(X'*X)*X'*y
  • How to choose gradient descent or normal equation ?

  • Use python to implement Normal Equation
import numpy as np

def normalEqn(X, y):
theta = np.linalg.inv(X.T@X)@X.T@y #X.T@X 等价于 X.T.dot(X)
return theta

7、Normal Equation Non-invertibility

8、Supplement

Machine learning(4-Linear Regression with multiple variables )的更多相关文章

  1. Machine Learning No.2: Linear Regression with Multiple Variables

    1. notation: n = number of features x(i) = input (features) of ith training example  = value of feat ...

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

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

  3. [Machine Learning] 多变量线性回归(Linear Regression with Multiple Variable)-特征缩放-正规方程

    我们从上一篇博客中知道了关于单变量线性回归的相关问题,例如:什么是回归,什么是代价函数,什么是梯度下降法. 本节我们讲一下多变量线性回归.依然拿房价来举例,现在我们对房价模型增加更多的特征,例如房间数 ...

  4. ML:多变量线性回归(Linear Regression with Multiple Variables)

    引入额外标记 xj(i) 第i个训练样本的第j个特征 x(i) 第i个训练样本对应的列向量(column vector) m 训练样本的数量 n 样本特征的数量 假设函数(hypothesis fun ...

  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. Andrew Ng Machine Learning 专题【Linear Regression】

    此文是斯坦福大学,机器学习界 superstar - Andrew Ng 所开设的 Coursera 课程:Machine Learning 的课程笔记. 力求简洁,仅代表本人观点,不足之处希望大家探 ...

  7. CheeseZH: Stanford University: Machine Learning Ex5:Regularized Linear Regression and Bias v.s. Variance

    源码:https://github.com/cheesezhe/Coursera-Machine-Learning-Exercise/tree/master/ex5 Introduction: In ...

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

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

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

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

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

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

随机推荐

  1. Vue指令及自定义指令的使用

    导航列表: 一.vue指令 二.自定义指令 一.vue指令 回到顶部    1. v-text v-text主要用来更新textContent,可以等同于JS的text属性,不会解析标签,会把标签解析 ...

  2. go案例:客户管理系统流程 mvc模式 分层设计

    下面是一个简要的客服系统,主要是演示分层计.. model : 数据部份: package model import "fmt" //声明一个结构体,表示一个客户信息 type C ...

  3. Django学习day13随堂笔记

    每日测验 """ 今日考题 1.什么是django中间件,它的作用是什么,如何自定义中间件,里面有哪些用户可以自定义的方法,这些方法有何特点 2.基于django中间件的 ...

  4. CDI 组件拦截器的使用和学习

    拦截器的作用原理: 声明拦截器,加@Interceptor注解 方法有二: 1)为拦截器添加Qualifier: 2)不添加Qualifier.为拦截器添加具体的拦截方法,该方法加@AroundInv ...

  5. linux centos系统 php安装GD库扩展

    yum --enablerepo=remi-php56 install php-gd php-mysql php-mbstring php-xml php-mcrypt //安装GD库扩展 servi ...

  6. Groovy系列(5)- Groovy IO操作

    IO操作 Groovy为I/O操作提供了许多帮助方法,虽然你可以在Groovy中用标准Java代码来实现I/O操作,不过Groovy提供了大量的方便的方式来操作File.Stream.Reader等等 ...

  7. Shell系列(13)- read

    前言 作用是往脚本中传递参数,之前文章的位置参数变量也有此功能,但是只适用于脚本的作者,为什么?第三方用户不知道这个脚本要传递哪些参数,这些参数分别是什么.本篇随笔read就可以实现上述功能,别且该命 ...

  8. P1074 [NOIP2009 提高组] 靶形数独

    #include<bits/stdc++.h> using namespace std; const int N=10; int a[N][N],ans[N][N],vis[3][N][N ...

  9. linux 修改文件名称的三中方法

    一:rename "old.html" "oldd.HTML" *html参数.有什么.改为什么 ,目标文件: 二 : #!/bin/sh Dirname=&q ...

  10. 启动springboot出现错误 Caused by: java.net.BindException: Address already in use: bind

    如果运行过程中出现端口被占用 抛出了这个异常 首先可以在cmd中调出命令窗口然后 执行命令 netstat -ano  可以查看所有活动的连接  找到你被占用的端口 可以看到我被占用的端口的进程是 4 ...