Machine Learning(Andrew Ng)学习笔记
1.监督学习(supervised learning)&非监督学习(unsupervised learning)
监督学习:处理具有若干属性且返回值不同的对象。分为回归型和分类型:回归型的返回值是连续的,分类型的返回值是离散的。
非监督学习:将具有若干属性的相同对象分为不同的群体。
2.线性回归模型(监督学习)
2.1 一些符号
m——训练样本数目
x——输入变量
y——输出变量
(x,y)——一个训练样本
(x(i),y(i))——第i个训练样本
h——假设(hypothesis)——预测函数
n——训练样本特征数目
$x_{i}$——训练样本的第i个特征对应的向量
$x^{(i)}$——第i个训练样本所有特征对应的向量
$x_{j}^{(i)}$——第i个训练样本的第j个特征
2.2 cost function
$J\left ( \theta _{0},\theta _{1} \right )= \frac{1}{2m}\sum_{i=1}^{m}\left ( h_{\theta }\left ( x^{(i)} \right )-y^{(i)} \right )^{2}$
$h_{\theta }(x)=\theta _{0}+\theta _{1}x$
2.3 梯度下降算法(gradient descent)
2.3.1 单特征:
$\theta _{i}:=\theta _{i}-\alpha \frac{\partial }{\partial \theta _{i}}J\left ( \theta _{0}, \theta _{1}\right ) (simultaneously\ for\ i=0\ and\ i=1)$
$J\left ( \theta _{0},\theta _{1} \right )= \frac{1}{2m}\sum_{i=1}^{m}\left ( h_{\theta }\left ( x^{(i)} \right )-y^{(i)} \right )^{2}$
$h_{\theta }(x)=\theta _{0}+\theta _{1}x$
即
$\theta _{0}:=\theta _{0}-\alpha \frac{1}{m}\sum_{i=1}^{m}\left (h_{\theta }(x^{(i)})-y^{(i)} \right )$
$\theta _{1}:=\theta _{1}-\alpha \frac{1}{m}\sum_{i=1}^{m}\left (h_{\theta }(x^{(i)})-y^{(i)} \right )\cdot x^{(i)}$
2.3.2 多特征:
$\theta _{i}:=\theta _{i}-\alpha \frac{\partial }{\partial \theta _{i}}J\left ( \theta\right ) (simultaneously\ for\ i=0\ to\ n)$
$\theta = \begin{pmatrix}\theta _{0}
\\\theta _{1}
\\\theta _{2}
\\...
\\\theta _{n}
\end{pmatrix}$
$x^{(i)} = \begin{pmatrix}x_{0}^{(i)}
\\x_{1}^{(i)}
\\x_{2}^{(i)}
\\...
\\x_{n}^{(i)}
\end{pmatrix}(x_{0}^{(i)}=1)$
$J\left (\theta \right )= \frac{1}{2m}\sum_{i=1}^{m}\left ( h_{\theta }(x^{(i)})-y^{(i)} \right )^{2}$
$h_{\theta }(x^{(i)})=\theta ^{T}x^{(i)}$
即
$\theta_{j}:=\theta_{j}-\alpha \frac{1}{m}\sum_{i=1}^{m}(h_{\theta}(x^{(i)})-y^{(i)})\cdot x_{j}^{(i)}$
2.3.3
批处理梯度下降("Batch" Gradient Descent):梯度下降的每一步都要用到所有训练样本的数据
2.4 优化方法
2.4.1 特征缩放(feature scaling)
$x_{j}^{(i)}:=\frac{x_{j}^{(i)}-\mu_{j}}{S_{j}}$
$\mu_{j}$为训练样本的第j个特征的平均值
$S_{j}$为训练样本的第j个特征的标准差(max-min)
2.4.2
(1)工作正确性检验
随着迭代次数(iteration)的增加,代价函数$J(\theta)$不可能增加
当$J(\theta)$减少量小于$\varepsilon $时,认为代价函数已收敛
(2)学习速率($\alpha$)选取
$\alpha$过小:收敛过慢
$\alpha$过大:无法保证每次迭代$J(\theta)$都不增加;无法保证收敛(solution:减小$\alpha$)
3 多项式回归
3.1
直接把f(x)作为一个整体当成$x^{(i)}_{j}$,即可把非线性回归转化为线性回归
3.2 数学方法直接求出最优解


3.3

Machine Learning(Andrew Ng)学习笔记的更多相关文章
- Machine Learning - Andrew Ng - Coursera
Machine Learning - Andrew Ng - Coursera Contents 1 Notes 1 Notes What is Machine Learning? Two defin ...
- Machine Learning|Andrew Ng|Coursera 吴恩达机器学习笔记
Week1: Machine Learning: A computer program is said to learn from experience E with respect to some ...
- Machine Learning|Andrew Ng|Coursera 吴恩达机器学习笔记(完结)
Week 1: Machine Learning: A computer program is said to learn from experience E with respect to some ...
- Coursera 机器学习 第6章(下) Machine Learning System Design 学习笔记
Machine Learning System Design下面会讨论机器学习系统的设计.分析在设计复杂机器学习系统时将会遇到的主要问题,给出如何巧妙构造一个复杂的机器学习系统的建议.6.4 Buil ...
- [Machine Learning] Andrew Ng on Coursera (Week 1)
Week 1 的内容主要有: 机器学习的定义 监督式学习和无监督式学习 线性回归和成本函数 梯度下降算法 线性代数回归 主要是了解一下机器学习的基本概念,重点是学习线性回归模型,以及对应的成本函数和梯 ...
- [Machine Learning (Andrew NG courses)]II. Linear Regression with One Variable
- [Machine Learning (Andrew NG courses)]IV.Linear Regression with Multiple Variables
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvenFoXzE5OTE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...
- Machine Learning With Spark学习笔记(在10万电影数据上训练、使用推荐模型)
我们如今開始训练模型,还输入參数例如以下: rank:ALS中因子的个数.通常来说越大越好,可是对内存占用率有直接影响,通常rank在10到200之间. iterations:迭代次数,每次迭代都会降 ...
- Machine Learning With Spark学习笔记(提取10万电影数据特征)
注:原文中的代码是在spark-shell中编写运行的,本人的是在eclipse中编写运行,所以结果输出形式可能会与这本书中的不太一样. 首先将用户数据u.data读入SparkContext中.然后 ...
随机推荐
- [转帖]k8s.gcr.io镜像无法下载的问题
k8s.gcr.io镜像无法下载的问题 https://blog.51cto.com/liuzhengwei521/2301497 看了下 赵安家老师应该是青岛人 在济南顺能网络科技有限公司上班 铭盛 ...
- Resistors in Parallel(找规律+大数)
题意:https://codeforces.com/group/ikIh7rsWAl/contest/254825/problem/E 给你一个n,计算n / Sigma(1~n)的d(是n的只出现一 ...
- Annotation Type ManyToMany->>>>>Oracle
Example 1: // In Customer class: @ManyToMany @JoinTable(name="CUST_PHONES") public Set< ...
- 【IntelliJ IDEA】快捷键
1.System.out.println();的快捷方法 sout然后Alt+Enter或者直接点 2.idea上 重写父类方法的快捷键 Ctrl+O之后,在弹出的上面选择要重写的方法 3.idea ...
- tomcat 虚拟目录 连接池
- Android 直连SQL
在工作中遇到需求需要Android直接连接SQL,看了一些人说不建议直连,但我对性能没有要求,甚至说只要在局域网内能够使用就行,简单说把手机当作一个简单的移动操作点. 代码的话,网上都有比如: htt ...
- C++ STL用法总结(持续更新)
Vector 动态数组 https://www.cnblogs.com/zhonghuasong/p/5975979.html lower_bound&&upper_bound htt ...
- location(重定向,跳转到其他网页)
<?php header('Location : https://www.baidu.com'); 这里是在响应头中添加一个 location 的头信息 客户端浏览器在接收到这个头信息过后会自动 ...
- vue 节流
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- django orm 数据查询详解
一 在django里面创建模型 from django.db import models class Blog(models.Model): name = models.CharField(max_l ...