一.概述
\quadCousera 上第一周的课程主要对机器学习的定义、分类进行了简单的介绍,同时对机器学习过程中一类简单的问题——单变量线性回归(Linear Regression with one variable)进行了讲解描述,通过对单变量线性回归这一类简单问题的学习,了解机器学习问题解决过程中所需要掌握的概念和公式(函数),个人认为通过第一周的学习之后能够把握机器学习的概念,掌握解决机器学习问题所需要的元素即可。

(关于Machine learning by Pro.Andrew Ng 的更多资源请关注图中微信公众号——针知与拙见 获取 )

  • 在第一周的学习中主要应当掌握以下几个主要概念

    • 机器学习的定义(Arthur Samuel and Tom Mitchell )
    • 监督学习(Supervised learning)
    • 无监督学习(Unsupervised learning)
    • 代价函数(Cost Function)
    • 梯度下降(Gradient Descent)

以及其中部分概念所对应的函数/向量表达式

1 单变量线性回归的模型表示(Model Representation of univariate linear regression)

——y^=hθ(x)=θ0+θ1xy^=hθ(x)=θ0+θ1x\hat y = h_\theta(x)=\theta_0+\theta_1x

2 代价函数(Cost Function)
——J(θ0,θ1)=12m∑mi=1(hθ(xi)−yi)2J(θ0,θ1)=12m∑i=1m(hθ(xi)−yi)2J(\theta_0,\theta_1)=\frac{1}{2m}\sum_{i=1}^m{}(h_\theta(x^i)-y^i)^2

3 梯度下降(Gradient Descent)
——θj=θj−α∂θ∂θjJ(θ0,θ1)(j=0,1)θj=θj−α∂θ∂θjJ(θ0,θ1)(j=0,1)\theta_j=\theta_j-\alpha\frac{\partial \theta}{\partial\theta_j}J(\theta_0,\theta_1)\quad( j=0,1)

带入函数假设(hypothesis)可以得到
——θ0=θ0−α1m∑mi=1(hθ(xi)−yi)θ0=θ0−α1m∑i=1m(hθ(xi)−yi)\theta_0=\theta_0-\alpha\frac{1}{m}\sum_{i=1}^{m}(h_\theta(x^i)-y^i)

——θ1=θ1−α1m∑mi=1(hθ(xi)−yi)(xi)θ1=θ1−α1m∑i=1m(hθ(xi)−yi)(xi)\theta_1=\theta_1-\alpha\frac{1}{m}\sum_{i=1}^{m}(h_\theta(x^i)-y^i)(x^i)

以上两式即为在单变量线性回归时对于θ0,θ1θ0,θ1\theta_0,\theta_1的参数更新方程

二.机器学习简介

1.机器学习定义

(1) The field of study that gives computers the ability to learn without being explicitly programmed —— Arthur Samuel

机器学习研究的是在计算机没有被明确编程的情况下学习的能力。

(2)Computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E—— Tom Mitchell

Example: playing checkers.
E = the experience of playing many games of checkers

T = the task of playing checkers.

P = the probability that the program will win the next game.

E.g:在跳棋游戏的例子中,任务T是玩跳棋游戏,P是游戏的输赢,E则是一局又一局的游戏

2.监督学习(Supervised Learning)

\quad——有标签(label)的机器学习

\quadIn supervised learning, we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output.

\quadSupervised learning problems are categorized into “regression” and “classification” problems. In a regression problem, we are trying to predict results within a continuous output, meaning that we are trying to map input variables to some continuous function. In a classification problem, we are instead trying to predict results in a discrete output. In other words, we are trying to map input variables into discrete categories.

\quad监督学习问题分为“回归”和“分类”问题。

(1)回归问题

definition——为算法提供样本特征值(feature)的同时给与样本结果(判定依据),算法通过对所给予结果回归得到具体模型。(算法通过回归构筑所给与结果与样本特征(feature)之间的联系),利用模型实现对连续值的预测。

在回归问题中,我们试图在连续输出中预测结果,这意味着我们正在尝试将输入变量映射到某个连续函数。

注:回归问题又可简单分为univariate linear regression
(单变量线性回归)、multivariate linear regression
(多变量线性回归)、Normal Equation
(正规方程)三种,在之后的学习中会详细介绍。

(2)分类问题

definition——为算法提供样本特征值(feature)的同时给与样本结果(判定依据),算法通过对所给予样本结果归类得到具体模型,利用模型实现对离散值的预测。

在分类问题中,我们试图在离散输出中预测结果。 换句话说,我们试图将输入变量映射到离散的类别中。

以下举例说明监督学习中的回归和分类问题:
例1:
\quad基于有关房地产市场房屋面积的数据尝试预测房价。 由于以房屋面积大小为自变量、房屋价格为因变量的函数为是连续输出函数,因此这是一个回归问题。
我们也可以通过规定一个价格限度来将这一回归问题变为分类问题,当房价高于这一价格限度时为一类别,当房价低于这一价格限度时为另一类别。

例2:
(a)回归 - 鉴于男/女的照片,我们必须根据给定的图片预测他/她的年龄。

(b)分类 - 鉴于男/女的照片,我们必须预测他/她是高中生,大学生还是研究生。 另一个分类示例 - 银行必须根据其信用记录决定是否向某人提供贷款。

3.无监督学习(Unsupervised Learning)

\quad——无标签(label)的机器学习

\quadUnsupervised learning, on the other hand, allows us to approach problems with little or no idea what our results should look like. We can derive structure from data where we don’t necessarily know the effect of the variables.

\quadWe can derive this structure by clustering the data based on relationships among the variables in the data.

\quadWith unsupervised learning there is no feedback based on the prediction results, i.e., there is no teacher to correct you.

\quad除监督学习外,机器学习的另一大类问题——无监督学习使我们能够在很少或根本不知道我们的结果应该是什么样的情况下处理问题。 我们可以在我们不知道各个变量对于结果的影响时,从数据中导出合理的结构(合理的结果)。

\quad我们可以通过基于数据中变量之间的关系通过聚类的方法来导出这种结构(合理的结果)。

\quad在无监督学习的情况下,没有基于预测结果的反馈,因为样本数据(所给予计算机学习的数据)中没有标签(label)。

例:
\quad聚类:收集1000篇关于美国经济的论文集,并找到一种方法将这些论文根据几个相似或相关的不同变量(如词频,句子长度,页数)自动分为几个类别。

\quad非聚类:“鸡尾酒会算法”,可以在混乱的数据中找到结构(例如在鸡尾酒会上从声音网格中识别个别声音和音乐)

三.单变量线性回归(univariate linear regression)

1.模型假设

\quad关于单变量线性回归的模型假设在上文中已经提到了——y^=hθ(x)=θ0+θ1xy^=hθ(x)=θ0+θ1x\hat y = h_\theta(x)=\theta_0+\theta_1x

在解决单变量线性回归问题时,我们需要用到的符号及其各自含义需要首先了解,它们具体是如下:

m:代表训练集中实例的数量

x:代表输入变量/特征

(x(i),y(i)):代表训练集中的第i个实例

(x,y):代表训练集中的实例

\quadNote that this is like the equation of a straight line. We give to hθ(x)hθ(x)h_\theta(x) values for θ0θ0\theta_0 and θ1θ1\theta_1 to get our estimated output y^y^\hat y.In other words, we are trying to create a function called hθ(x)hθ(x)h_\theta(x)that is trying to map our input data (the x’s) to our output data (they’s).

\quad需要注意的是,我们需要做的是寻找最合适的参数 θ0θ0\theta_0 和θ1θ1\theta_1 使得已有数据点实现最大程度的拟合。(在单变量线性回归问题中不存在过拟合问题,而在后面的课程中所学到的多变量线性回归(Multivariate linear regression)问题中则会存在)

2.代价函数 (Cost Function)

\quad我们可以使用代价函数来衡量我们的模型假设函数的准确性,这就需要对将x带入模型假设所求得的y^y^\hat y与实际的样本输出y作比较,具体见下式:

J(θ0,θ1)=12m∑mi=1(y^i−yi)=12m∑mi=1(hθ(xi)−yi)2J(θ0,θ1)=12m∑i=1m(y^i−yi)=12m∑i=1m(hθ(xi)−yi)2J(\theta_0,\theta_1)=\frac{1}{2m}\sum_{i=1}^m {}(\hat y_i-y_i)= \frac{1}{2m}\sum_{i=1}^m{}(h_\theta(x^i)-y^i)^2

\quad此函数另外称为“平方误差函数”或“均方误差函数”。将平均值减半以便计算梯度下降,因为在梯度下降时对平方函数求导后的2将抵消此处的1/2。现在我们能够根据我们的已有结果具体测量预测函数的准确性,以便我们可以预测新的结果。

\quad注意:我们的目标是获得最佳拟合直线,这条直线使得样本数据到拟合直线沿y轴方向的距离最小。 在最好的情况下,该线应该通过我们的训练数据集的所有点,那么这时代价函数J(θ0,θ1)J(θ0,θ1)J(\theta_0,\theta_1)的值即为0。

3.梯度下降 (Gradient descent)

\quad当我们拥有代价函数后,我们就有一种方法可以衡量模型假设函数与数据的匹配程度。而现在我们要做的就是估计假设函数中的参数,通过调整模型假设函数中的参数使得代价函数(Cost Function)最小。 这就是梯度下降的作用,其就是用来求代价函数(此处为代价函数)最小值的函数(算法)。

\quad梯度下降函数(算法)通过以一定学习率不断更新代价函数以求得代价函数的局部最小值(注意:不一定为全局最小值)。
\quad其在单变量线性回归问题中的形式为:

θ0=θ0−α1m∑mi=1(hθ(xi)−yi)θ0=θ0−α1m∑i=1m(hθ(xi)−yi)\theta_0=\theta_0-\alpha\frac{1}{m} \sum_{i=1}^{m}(h_\theta(x^i)-y^i)

θ1=θ1−α1m∑mi=1(hθ(xi)−yi)(xi))θ1=θ1−α1m∑i=1m(hθ(xi)−yi)(xi))\theta_1=\theta_1-\alpha\frac{1}{m} \sum_{i=1}^{m}(h_\theta(x^i)-y^i) (x^i))

在上式中,m为训练集的大小,梯度下降算法将以一定的学习率同时更新θ0θ0\theta_0,θ1θ1\theta_1 ,以求得代价函数的最小值。如果我们从猜测开始,然后重复应用这些梯度下降方程,我们的假设将变得越来越准确。


\quad文中部分英文原文取自Pro.Andrew Ng 于cousera上发布的Machine learning 公开课的Week 1 Lecture Notes。其他内容均由个人整理撰写,如需要更多机器学习的学习资源欢迎关注微信公众号:针知与拙见并在后台留言。
[1] https://www.coursera.org/learn/machine-learning/
[2] 微信公众号——针知与拙见

Week 1——Machine learning by Pro.Andrew Ng (cousera)——notebook相关推荐

  1. Machine Learning课程 by Andrew Ng

    大名鼎鼎的机器学习大牛Andrew Ng的Machine Learning课程,在此mark一下: 一:Coursera: https://www.coursera.org/learn/machine ...

  2. 【Machine Learning】【Andrew Ng】- Quiz2(Week 9)

    1.Suppose you run a bookstore, and have ratings (1 to 5 stars) of books. Your collaborative filterin ...

  3. 【Machine Learning】【Andrew Ng】- notes(Week 1: model and cost function)

    Model Representation: To describe the supervised learning problem slightly more formally, our goal i ...

  4. Machine learning week 10(Andrew Ng)

    文章目录 Reinforcement learning 1. Reinforcement learning introduction 1.1. What is Reinforcement Learni ...

  5. 【Machine Learning】【Andrew Ng】- notes(Week 2: Computing Parameters Analytically)

    Normal Equation Gradient descent gives one way of minimizing J. Let's discuss a second way of doing ...

  6. 【Machine Learning】【Andrew Ng】- Quiz1(Week 8)

    1.For which of the following tasks might K-means clustering be a suitable algorithm? Select all that ...

  7. Machine Learning Outline(Andrew Ng课程总结)

  8. [导读]7 Steps to Mastering Machine Learning With Python

    Step 1: Basic Python Skills ▪  Python The Hard Way by Zed A. Shaw ▪  Google Developers Python Course ...

  9. 【github】机器学习(Machine Learning)深度学习(Deep Learning)资料

    转自:https://github.com/ty4z2008/Qix/blob/master/dl.md# <Brief History of Machine Learning> 介绍:这 ...

  10. 机器学习(Machine Learning)深度学习(Deep Learning)资料汇总

    本文来源:https://github.com/ty4z2008/Qix/blob/master/dl.md 机器学习(Machine Learning)&深度学习(Deep Learning ...

最新文章

  1. Java“地铁”表(JavaFX)
  2. Linux网络编程一步一步学-UDP方式点对点通讯
  3. NPOI导出Excel2007-xlsx
  4. LINUX mysql 源码安装
  5. KM算法(最优匹配)
  6. 图像扩充边界_使用机器学习来索引数十亿图像中的文本
  7. Combinations leetcode 组合问题
  8. ezcad旋转轴标刻参数_激光打标机软件ezcad系统参数设置
  9. 几个常用的C语言编程工具,极力推荐!
  10. 使用nodejs pkg创建exe文件后更改图标
  11. ArangoDB查询语言(AQL) 基本语法用法
  12. 周信东c语言实验二实验报告,实验三 循环结构程序设计参考答案
  13. 神经网络与深度学习编程练习(coursera 吴恩达 )(3)
  14. 一篇文章读懂什么是大数据
  15. Web全栈~05.CSS属性
  16. android 文字滚动组件,Android textview 跑马灯文字滚动效果
  17. android+模拟人体扫描,人体模型模拟器app
  18. 北航计算机学院2019录取分数 线,北京航空航天大学录取分数线2019(在各省市录取数据)...
  19. 基于双阶段度量学习的跨模态行人再识别
  20. NSI 脚本 -注册表操作无法正常找到的问题

热门文章

  1. 计算机专业考研是英语几,计算机考研考英语一还是英语二
  2. /sys/kernel/debug及debugfs
  3. C# 实验三 面向对象程序设计(一)
  4. BUAA(2021春) 北京地铁乘坐线路查询——Dijkstra和Floyd双解法
  5. word输入对号以及带框的对号
  6. vs2012窗体嵌入表格_2012年电子表格日
  7. c盘满了怎么清理垃圾而不误删?教你瞬间多出20个G
  8. 程序员5种编程入门方法,如何快速学会一门编程语言?
  9. 周杰伦专辑《最伟大的作品》在哪看?当贝盒子畅享周董最新MV
  10. chrome下载提示网络错误