Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning  by Andrew Ng on Coursera 

      机器学习是近年来的一大热门学科,本人对此非常感兴趣,正好本学期学校开设机器学习MOOC课程,可以学习Coursera正版机器学习课程,于是决定每周在此总结学习的内容与大家分享。

Week1:

第一周的内容不多,主要是介绍一些基础知识,初步讲解代价函数和梯度下降法。

What is machine learning? –A computerprogram is said to learn from experience E with respect to some class of tasksT and performance measure P. If its performance as tasks in T, as measured byP, improves with experience E.

Supervised Learning 监督学习:

 know what correct output should look like.

  • regression continuous output (eg : predict the house price) 
  • classification discrete output (eg : predict whether the tumor is malignant or benign)

Unsupervised Learning 非监督学习:

Approach problems with little or no idea what our results should look like.

Model Representation:

m = Number of training examples

x = input variable/features

y = output variable/target variable

(x,y) = one training example

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Cost Function 代价函数

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

代价函数越小,函数对原数据对拟合越好。如上图可以看出,Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)时,Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)对原数据拟合的最好,通过了所有的点,此时可以看到,Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)取到最小值0。

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

同样,在二维特征的情况下,如上图所示,Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)的图像为一个三维曲面,同样,在Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)取最小值时,函数的拟合情况最好。

因此学习算法的优化目标是找到一组 Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结) 的值来将 Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结) 最小化。

Gradient Descent梯度下降:

知道了cost function的作用以及其与函数拟合情况的关系后,就需要有方法来求出使代价函数最小的参数值,其中之一即是gradient descent。

gradient descent的原理:想象一下你正站立在山上 想要快速下山,在梯度下降算法中,我们要做的就是旋转360度,看看我们的周围,并问自己,如果我想尽快走下山,这些小碎步需要朝什么方向?在山上的新起点上,你环顾四周,并决定从什么方向将会最快下山,然后又迈进了一小步,又是一小步,并依此类推,直到局部最低点的位置。

repeat until convergence{

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

}


Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结) means assign b to a。

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结) is the learning rate, it can control the update step-size of Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

if Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结) is too small, gradient descent can be slow;

if Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结) is too large, gradient descent can overshoot the minimum, it may fail to converge, or even diverge.

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

Machine Learning by Andrew Ng on Coursera Week1(Coursera机器学习课程第一周总结)

如上图所示,执行梯度下降时,据你设定的初始值的不同,你可能会得到不同的局部最优解。