刘小邦的个人博客分享 http://blog.sciencenet.cn/u/iamliuzhiyong 浮生浪迹笑明月 千愁散尽一剑轻

博文

[机器学习]Standford Machine Learning Course by Andrew Ng

已有 4922 次阅读 2013-5-24 19:33 |个人分类:机器学习|系统分类:科研笔记

欢迎词

欢迎来到machine learning! 今天mark这门课程的开始!(一个多么native的英文单词啊,mark。) 学好了这门课,就可以知道如何应用最先进的machine learning algorithm解决很多具体问题了。这包括anti-spam,image recognition,clustering,building recommender system等等很多很强大的应用。希望与大家一起来学习!

其实,在你学习之前,你已经使用了很多基于machine learning的应用了。每一次你使用google或者bing的时候,这些searcher都需要学习如何rank网页。每次你使用facebook或者Apple的photo typing application来recognize你的朋友,你同样用到了machine learning。每次你使用你的email,其中的spam filter免除你受到tons of spam的骚扰(saves you from wading through tons of spam,纯正的英文!)。

这一课你将学到state-of-the-art的machine learning algorithm,但是如果只知道algorithm和math,而不知道如何让其实际解决问题也是不够的。 因此我们同时spend a lot of time来设计exercise,在exercise中实现相关的算法,观察实际的效果。为什么machine learning在今天如此的prevalent?因为我们想要设计intelligent system,很多基本的things只需基本的program a machine,例如发现从A到B的shortest path。但是对于most part,我们并不知道如何去write intelligent program,来做更有趣的事情,例如web search,photo tagging或者anti-spam。唯一的realization方法就是machine learning。Machine learning已经发展成一个新的计算机的capability,并且touch了industry和basic science的很多segments。(it touches many segments of industry and basic sciences, 想想中国人的表达会如何!)

对于我来讲,平均每两三周就会受到来自silicon valley的email,联系我应用machine learning的方法到他们的own problem。This is a sign of problem that machine learning touches. 不仅有autonomous robotic,computational biology,还有tons of problem都需要machine learning。Data minning如此pervade的重要原因是growth of web pages以及growth of automation。成千上万的sillicon valley的公司不停的收集web click data,或者叫clickstream data(矮油,新名词儿!)随着automation的到来,我们拥有electronic medical record,我们可以turn这些medical record变成medical knowledge,这样我们便可以更好的understand这些disease。With automation again,biology需要收集gene sequence的大量数据。machine learning可以用于更好的understand人类genome. 第二range的application,就是那些我们不能通过hand来program的问题,比如autonomous helicopter,我们不知道如何让helicoptor 知道如何自己编程。唯一的方法是让computer自己学习如何让helicopter自己飞行。此外还有handwriting recognition,之所以在不同的国家间route邮件如此便宜,是因为machine learning algrithm用来learn信封上的handwriting。这样,便可以autonomatically route信封。It cost a few cents to send this thing thousand of miles。事实上,你也看到了其他的一些field,比如natural language processing和computer vision。这是一个AI pertaining to 理解language和images的field。(pertaining to,高级英文词儿,一股高富帅的气息)大多数的natural language processing和computer vision都在应用machine learning。初此之外,还有customized recommendation。最后,learning algorithm今天被用来understand human learning and unstand the brain。(这里有一股浓重的玄学味道!)

几个月前,一个学生给我看了一篇article,上面描述了top 25的IT skill。这是一个slightly order artichle,其实最top desirable的IT Skill是machine learning。在standford,ther number of recruiter联系我需要一些machine learning student,远超我们每年machine learning毕业的学生。这是一个vast,并且unfulfilled 的demand。(不得不承认unfulfilled是一个好词儿). 现在是一个很好的时刻去学习machine learning。下一节,我们将给出machine learning的formal defination,以及主要的type的machine learning problem。

什么是machine learning?

本节将define什么是machine learning,并且给大家一个sense哪里需要用到machine learning。尽管在machine learning的practitioner中,依然没有一个well-accepted的定义。Arthur Samuel给出了一个machine learning的定义:machine learning是一个使得计算机withou explicit programing而能够学习的研究领域。Samuel的claim to fame(clain to fame 成名之作!),是在1950年代写的checker playing program. 非常迷人的是samuel自己并不是一个好的checker player。其方法是观察tens of thousands的games,观察什么样的posion可以win或者lose。该checker learn program根据棋局over time的学习。(over time,随着时间过去!) 最终变成了一个比Samuel自己更好的checker。这是一种informal的定义。最近由Carnegie Mellon大学的Tom Mitchell给出了machine learning的新的定义。简单来讲,machine learning就是依据experience E,task T在performance measure P的量测下有improve。对于checker playing example,experience E就是拥有成千上万次的game,task T就是play checkers,而performance P就是可以赢得next game的probability。我occasionally会问一些问题,来确保你明白讲授的content。machine learning主要分为两种类型supervised learning和unsupervised learning。Supervised Learning是告诉computer如何做事,而unsupervised learning是自我学习。同时你也可能听到一些其他的一些term,比如reinforcement learning和recommender system。在本课程中,你还会学到一些如何应用learning algorithm的practical advice,这一点我有强烈的感觉。Teaching learning algorithm就像给你一些解决问题的tools,equally important or more important(常用的转折in the presentation!) 是教给你如何应用这些tools。我想做个教授工匠的比喻(I like to make an analogy to,绝逼提高理论阐述能力!)。那些知道如何使用这些工具的人versus那些不知道使用这些工具的人有着极大的不同。当我走进silicon valley,尽管是那些顶尖的company,可以看到他们尝试在一些具体问题上应用machine learning算法。有些时候,他们花了六个月的时间在have being going at。我告诉他们其实六个月之前,你们可以选择一个machine learning algorithm,做一些slightly modified algorithm,你们取得成功的的chance会much higher。所以在这个课程中,我们将花费很多时间来教授如何develop一个machine learning algorithm,以及如何对选择算法make best decision。

什么是supervised machine learning?

这一课重点介绍supervised machine learning的property。正式的definition会在后面给出,supervised machine learning的property通过一系列的example来体现。让我们来看house predicted prices,一个学生从曾Institue of Portland Oregon获得一个data set, 我们来plot这个数据集。horizontal axis(这个词儿太值得脱口而出了!)代表房屋尺寸 in square feet,以及vertical axis代表不同房屋的价格in thousands of dollars。假设你有一个朋友拥有750 square feet的房子, 想知道房子的价格。这learning algorithm如何帮助你呢? 一种learning algorithm的方法是put一个通过数据的straight line,基于此,看起来房屋价格可以在150,000售出。但这并不是唯一的可以利用的machine learning algorithm。还有其他的方法,举个例子,我们可能decide用quadratic function或者二阶的polynomial function来fit这个数据。下面我们要讲的是如何choose和decide用什么样的function来fit,quadratic function还是polynomial function,但并没有fair picking哪个一个可以给出更好的销售price。这是一个supervised learning的example。 Supervised 指的是我们给这个algorithm一个包含correct answer的dataset。定义这个terminology,这也可以称为regression problem。通过regression problem,我们尝试去预测continuous value output。Techniquely,房屋的价格可以round off到最近的cent。因此price实际上是discrete value,通常被认为是real value,作为continuous value。regression指的是我们尝试去预测continuous value的attribute。这里有另外一个我之前实际参与过的supervised learning example,让我们来看这个medical records,来预测malignant或者benign的(这两个词一出,谁与争锋!)breast cancer。一些人发现有breast tumor,malignant tumor是harmful并且dangerous的,但是benign tumor是harmless的。所以人们都很关心,让我们来观察一些dataset,dataset的horizontal axis是tumor的size值,vertical axis值是0或者1,其中1是malignant,0是non-maligant或者benign。我们的dataset中,这种tumor size发现是benign,另外的一些tumor size是malignant。我们有5个benign tumor的例子,还有5个maligant tumor的例子。let's say(这是一个频率极高的短语!引导一个一个实例!)我们有一个朋友tragically(这是一个多么感性的词啊!)拥有一个breast tumor。let's say这个breast tumor的size在这个值附近。The machine learning problem是能否估计出tumor为malignant还是benign的概率。定义这个terminology,这可以称为classification problem。Classification指的是我们尝试去predict一个离散的结果,0或者1,benign或者malignant。It turn out that(频率非常高的用词!引导一个现象!)有时候classification problem有时候拥有超过两个的value。一个具体的example是可能有超过三种cancer。Tumor size是一种attribute用来预测malignancy或者benignness。I am going to(频率非常高的用词!引导一个行为!)画O来denote良性肿瘤,使用X来denote恶性肿瘤。在其他的example中,超过一个feature,超过一个attribute,let's say除了tumor size还有patient age和tumor size。在这种情况下,tumor size可能会像这样,machine learning algorithm可能会throw一个straight line来分隔两类tumor。我们希望你的朋友的tumor决策为benign side。在这个例子中,我们有two features,分别是the age of patient和size of tumor。在其他的machine learning的algorithm中,我们通常拥有超过两个的feature,事实上我用了其他的feature,例如clump thickness of breast tumor,Uniformity of cell size,Uniformity of cell shape。那如何处理infinit number的feature呢,如何存储infinite number的data呢。让我们谈论下support vector machine,有一个允许computer去处理infinite number of feature的mathematical trick。Image我写下infinite number of feature,我们将come up with一个可以处理infinit number of feature的算法。所以,just recape,supervised learning是data set包含correct answer的learning algorithm,比如预测房屋的价格,预测tumor是maligant还是benign。我们同时讨论了regression problem,其目标是讨论discrete value output。下一节,我们将讨论unsupervised learning,这是另外一个主要的catograry。

什么是Unsupervised Learning

这个Video,我们主要talk about第二种主要类型的machine learning algorithm,这就是unsupervised machine learning。在上一个video,我们talk about supervised machine learning。 Back then(回顾当时),recall像这样的dataset,其中任何一个example都被label为positive或者negative,分别代表benign和malignant tumor。所以对于每个supervised learning algorithm,我们被explictly告知所谓的正确答案,属于benign还是malignment。在Unsupervised learning,我们给的数据不包括任何的label。我们没有被告知我们应该怎么做,每个dataset point是什么。Instead,我们被告知这是一个dataset,你可以从dataset中发现一些数据结构吗? 给定一个dataset,unsupervised learning algorithme可能会决定这个dataset包含两个cluster。 这是一个cluster,这是另外一个不同的cluster。

Unsupervised Learning algorithm可能会 break 这个数据集 into 两个 cluster中,这就是一个cluster algorithm。This turned out 用于很多地方。一个使用clustering算法的例子就是google news。如果你之前没有用过,你可以go to the URL: news.google.com去have a look at。Google news所呈现的是每天tens of thousands of news并且group他们in cohesive stories(united and working together effectively)。举个例子,the URLs 链接到不同的和BP Story相关的新的Story。 让我们click on这些story中的一个。What I will get 是一个像这样的web pages。这里是一个关于BP oil soill story的Wall street journal article,如果你click on diffent URL,你可以看到不同的story。这里是一个关于BP spill的CNN story。如果你click on 第三个连接,你会得到一个不同的story,这里是关于BP oil spill相关的UK guidian story。所以Goolge News所作的就是Group成千上万的新的story,并且自动的cluster them together。所以所有关于同一个故事的新闻get displayed together。It turn out that clustering算法和unsupervised learning algorithm在其他一些应用中表现也会不错。这里有一个关于理解geonomics有关的应用。这里有一个关于DNA microarray data的例子。The idea是group不同的individual,而对每一个量测how much他们拥有或者不拥有一个特定的gene。 Technically,你量测多少gene被表达。所以这些颜色,red, green, gray还是其他,显示了他们拥有一个specified gene的程度。你可以做的是运行一个clustering algorithm,并且Group individual into不同的category,或者Group individual into不同的people。这就是Unsupervised learning algorithm,因为我们并没有被告知这是type 1,那些是type 2,等等。相反,what are saying是这里有a bunch of data,我不知道数据里的类型,你可以automatically发现数据的类型,automatcially clustering the individuals into我们预先不知道的类型。因为我们并没有提前给出example in the dataset一些问题的答案。 Unsupervised learning或者clustering用于a bunch of other application。这常用来organize大型的computer cluster。我有一些朋友有在look at large data center,尝试fingure out哪些machine工作在一起。你可以把这些machine放在一起,这样的data center就会更有效地工作。第二个应该是social network application。给出关于哪个朋友会最多email的knowledge,我们是否可以identiy the cohesive group. 很多公司拥有a huge dataset of顾客信息, 你可以look at这些dataset,自动发现market segment,或者group这些customer into market segment。这样你就可以有效地或者自动的sell你的产品到不同的market segment。Again,这就是unsupervised learning,因为我们并不提前知道market segments是什么。我们必须让algorithm从数据中发现这些。最后,unsupervised learning也可以惊奇的用于astronomical data analysis,这种算法会给出如何银河系诞生的算法。所有的这些都是clustering的例子,这只是unsupervised learning的其中一种算法。让我来告诉你另外一个。我将告诉你cocktail parties problem,你之前曾去过cocktail parties。你可以想象这里有过一个party,room full of people,同时有很多overlapping voice,因为所有人都在讲话。你发现很难听清你面前的人讲的话。也许一个cocktail party只有两个人在一起讲话,我们放置两个麦克风,因为这两个麦克风在不同的距离,每个麦克风record不同voice speaker的combination。也许speaker 1 在microPhone 1 会比较louder,而speaker 2会在 microphone 2 比较louder。因为这两个microphone位于距离speaker不同的位置,但是每个microphone记录了不同的组合。这是两个不同speaker的natural recording。我们可以做的是take两个microphone recording,给他们unsupervised learning algorithm。让这个算法从dataset中发现data structure。这个算法所做的是listen the recording,并能区分输出不同的声音。

Linear Regression with One variable

Model representation

superscript就是上标的意思,subscript是下标的意思。Supervised Learning algorithm工作的原理如下:我们首先得到一个training set,就像那个house price的训练集,然后我们feed这个训练集给learning algorithm,learning algorithm的工作负责产生hypothesis,hypothesis的功能就是输入一个新的dataset,或者example,尝试output新的估计值。hypothesis就是一个可以map from x to y的function。只有一个variable的linear regression,就是univariate linear regression。

cost function

如何计算linear regression中的两个parameter能更好对应一个good fit呢? 理想是我们将选择parameter使得h(x),which mean the predicted value,接近于训练集中的example。cost function意味着发现theta 0 和theta 1的值让cost funtion to be minimized。We are posing 这个问题作为发现theta 0和theta 1的值,这样average already one over two M times the sum of square errors betwwen the prediction on the training set minus the actual values。这种cost function,其实也是square error function。The square error function可能是最常用的cost function之一。Hyphothesis是一个dataset为参数的function,相反,cost function是parameter theta为参数的function。 

 gradient descent

gradient descent Intuition; gradient Descent For linear regression

Support Vector Machines

到目前为止,我们已经学习了a range of different learning algorithms。(a range of, a wide range of) 在supervised learning范围内,很多supervised learning algorithm的性能是很类似的,when that is less more often be whether you use algorithm A or algorithm B。(that is less often be,不经常的意思)but when that is small there will often be the amount of data you are creating these algorithm on。当你应用这些算法的时候,有些永远的技能。比如选择给learning algorithm的feature,如何选择reguralization parameter。有一个powerful并且widely-used within industry and academia的学习算法,称为support vector machine。比较linear aggresion和neural network,support vector machine有时候会给出一个更powerful更cleaner的方式,来学习nonlinear complex functions。让我们take这个录像来谈谈这个。 Latter in the video,我会对不同的learning algorithm使用do a survay,简要的describe them。考虑到support vector machine的popularity和how powerful it is,他是supervised learning algorithm的最后一部分,我将spend a significant amount of time来介绍。 我们开始讨论optimization objective,let's get started on the algorithm,首先谈谈logistic regression。让我们show如何modify the logistic regression,从而essentially得到support vector machine。对于logistic regression,我们拥有familiar form的hypotheses,就是sigmoid activation function。(activation function)。为了解释一些math,我们用z来denote therata transponse times x。让我们想想logistic regression是怎样做的? 如果我们拥有一个example, y=1,不论是training set,还是test set。We are hoping h(x) close to 1。(约等于就是close to) 这意味着theta transpose x much larger than 0。(much larger 就是远大于的意思 greater greater sign就是远大于号)。当z是much better than 0,far to the right of the figure的时候。Logistic regression的输出接近于1。Conversely,如果我们有一个example,y equal to 0,我们期望output这个值接近于0, 这correspond theta transponse time x 远小于0。如果你看logistic regression的cost function,你会发现每个example,都contribute to这个cost function。所以对于overall cost function, 我们对所有的training example进行求和。这个函数contribute to单个example对overall objective函数的贡献。如果我们take the definition of full hypothesis,并且plunge in。我们将要采取这个cost function,minus log one over one plus e to negative z,做小小的修改。让我们take one out of here。让我们画这个将要使用的function,新的function可能将会从这里开始flat,我们也将产生一些grow as straight line。类似于logistic regression。所以我画的curve in magenta。它非常接近于logistic regression,除了他是由两个line segment组成的。这是一个flat portion on the right,这是一个line portion on the left。不要担心the slop of the straight line。(slop是斜率的意思)这是我们将要使用的新的function。你可以做很多pretty similiar的cost function。It turn out thats这会给出support vector machine计算上的advantages。这会产生更容易的optimization problem。我们只讨论了y equal 1,另外一个例子是y equal to 0。在这个case中,只有第二个term可以apply。cost function可以按照这个function给出。左边的cost function称为cos subscript 1 of z(subscript 1 of)。Armed with the definition,我们已经准备来build the support vector machine。这是应用于logistic regression的cost function。minimization problem one over m , sum my training example of y(i) times cost one of theta transponse times x(i) plus one minus y(i) times cos zeor of theta transponse x(i) and plus my usual regulation parameter。By convenction of support vector machine,

 

 

 

Reference

https://class.coursera.org/ml-003/class/index

 

 

 



https://blog.sciencenet.cn/blog-942948-693175.html

上一篇:[论文阅读]基于深度图像的室内移动机器人的快速人形检测
下一篇:[论文阅读]通过Dictionary Learning的视觉跟踪和运动估计
收藏 IP: 111.37.7.*| 热度|

1 韩书庆

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-3-29 12:58

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部