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. Verilog RTL优化策略(一):推荐使用assign语法替代if-else和case语法

    参考 <手把手教你设计CPU--RISC-V处理器篇> 先给出不用if-else和case的原因 Verilog中的if-else和case语法存在两大缺点: 不能传播不定态X: 会产生优 ...

  2. JetBrains 系列软件汉化包 2017.3-2018.1

    JetBrains 系列软件汉化包 关键字: Android Studio 3.0-3.1.3 汉化包 CLion 2018.1-2018.2 汉化包 GoLand 2017.3.2-2018.2 汉 ...

  3. Powershell 命令行安装 Windows 作业系统

    使用 powershell 完全安装或重灌 windows 作业系统的正确姿势 note:完全使用 powershell 指令,绝非在 powershell 终端下键入传统的 cmd 指令使用传统的 ...

  4. PHP的OpenSSL加密扩展学习(三):证书操作

    关于对称和非对称的加密操作,我们已经学习完两篇文章的内容了,接下来,我们就继续学习关于证书的生成. 生成 CSR 证书签名请求 CSR 是用于生成证书的签名请求,在 CSR 中,我们需要一些 dn 信 ...

  5. LINUX服务器带宽跑满、负载过高问题排查

    1.centos 安装流量监控iftop apt-get  install iftop -y 2.查看网卡名称 ifconfig 3.查看端口占用情况 iftop -i 网卡名称 -P 执行 nets ...

  6. PHP 相对路径转换为绝对路径 realpath

    * 相对路径 -> 绝对路径 realpath <?php /** * @param string $in_rel: relative directory * @param string ...

  7. P1758-[NOI2009]管道取珠【dp】

    正题 题目链接:https://www.luogu.com.cn/problem/P1758 题目大意 给出一个大小为\(n\)和一个大小为\(m\)的栈,每次选择一个栈弹出栈顶然后记录这个字母,求所 ...

  8. 淘宝商品html--网页结构

    淘宝商品html--网页结构 本篇爬虫紧接上一篇关于 泸州老窖 的爬虫随笔: import re import json def get_space_end(level): return ' ' * ...

  9. Python爬虫--淘宝“泸州老窖”

    爬虫淘宝--"泸州老窖" 爬去淘宝"泸州老窖" 相关信息: import requests import re import json import panda ...

  10. SpringBoot入门报错 Whitelabel Error Page的总结

    刚入门SpringBoot,编写helloControl类,去访问本地端口,无缘无故报了这个错误 Whitelabel Error Page 总结了下,目前我碰到的有三种会导致这种情况 1.当你的 S ...