机器学习介绍

机器学习的定义(Machine Learning Definition)

Even among machine learning practitioners there isn’t a well accepted definition of what is and what isn’t machine learning. But let me show you a couple of examples of the ways that people have tried to define it.

  • Arthur Samuel(1959). Machine Learning: Field of study that gives computers the ability to learn without being explicitly programmed. (This is an older, informal definition.)

  • Tom Mitchell(1998) Well-posed Learning Problem: A 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.

    Example: playing checkers.
    E = the experience of playing many games of checks
    T = the task of playing checkers
    P = the probability that the program will win the next game

Question:
Suppose your email program watches which emails you do or do not mark as spam, and based on that learns how to better filter spam. What is the task T in this setting?
A. Classify email as spam or not spam.
B. Watching you label emails as spam or not spam.
C. The number (or fraction) of emails correctly classified as spam/not spam.
D. None of the above, this is not a machine learning algorithm.

我们通过Tom Mitchell教授对机器学习的定义可知,问题选项中:A即为Task T,B即为Experience E,C即为Performance measure P。

机器学习的算法(Machine Learning Algorithms)

In general, any machine learning problem can be assigned to one of two broad classifications:

  • Supervised learning, the idea is that we’re going to teach the computer how to do something;
  • Unsupervised learning, we’re going let it learn by itself.

通常我们说的增强学习(Reinforcement Learning)和推荐系统(Recommender systems)这些其他类型的算法也是属于机器学习算法。

监督学习(Supervised learning)

我们先从一个例子开始:假设你需要预测房价,之前某个学生已经从某地收集了数据集,其中一个数据集如图所示:

房价数据

图中的每一个实例都为一次房屋交易,其中横坐标为不同房屋的面积,纵坐标为房屋交易价格。

根据给定的数据,假设你朋友有栋750平方英尺的房屋想要你帮忙把房价定多少合适且可以将房屋卖掉。

那么,学习算法怎么帮你朋友呢?学习算法可以:绘出一条直线,让直线尽可能匹配到所有数据。基于此,你可以估计这栋房屋可以买到15万美元。但这不是唯一的学习算法,这里使用平方函数可能会更好,即使用二次多项式可能更符合数据集。如果基于此的话,这栋房屋价格可以定价到20万美元。这里我们先留下一个疑问是选择直线呢还是选择平方函数来拟合。我们到后面再来回答这个疑问。这里所用的两个学习算法如图所示:

学习算法演示

其中,紫色的线条表示直线的学习算法,蓝色的线条即表示平方函数的学习算法。

这个预测房价的例子即是监督学习的例子。因此,监督学习意指预先给出一个算法的“正确结果”——即通过已有的数据集建立某种函数关系得出相应的结果。监督学习又称为回归问题,意指要预测一个连续值得输出。

接下来,我们再看一个监督学习的例子。现在步入到医学领域,我们想要预测胸部肿瘤是恶性还是良性。假设我们有如图所示的数据集,在数据集中,横轴表示肿瘤的大小,纵轴通过0(NO)和1(Yes)表示是否为恶性。

胸部肿瘤数据集

现在假设某人的肿瘤大小如图中的紫色箭头所示,预测该人所得的肿瘤是良性还是恶性。

此时,对应的机器学习的问题就是计算该大小的肿瘤是良性还是恶性的概论。专业地说,这是个分类问题,意指要预测一个离散值的输出。在分类问题中,预测离散值的输出有时会超过两个值。

同时,还有另外一种作图方式来描述数据集,即采用圆圈的方式表示良性肿瘤,画×的方式表示恶性肿瘤,如图所示:

这时,我们可以将一开始的数据集的数据映射至我们上图所示的数据集。除此之外,我们还拥有病人年龄和肿瘤大小关系的数据集,以及某人的肿瘤大小和年龄如图中紫色箭头所示:

那么依据这些给定的数据集,学习算法所做的就是画一条直线,分开恶性肿瘤和良性肿瘤,然后我们就能判断该人的肿瘤是否为恶性肿瘤了。

总结
  • 监督学习的基本思想为:在监督学习中,对于数据集中的每个数据,都有相应的“正确答案”——训练集,算法就是基于这些来做出预测。
  • 回归问题,即预测一个连续值输出。
  • 分类问题,目标是预测离散值输出。

Question:
You’re running a company, and you want to develop learning algorithms to address each of two problems.

  • Problem 1: You have a large inventory of identical items. You want to predict how many of these items will sell over the next 3 months.
  • Problem 2: You’d like software to examine individual customer accounts, and for each account decide if it has been hacked/compromised.

Should you treat these as classification or as regression problems?
A. Treat both as classification problems.
B. Treat problem 1 as a classification problem, problem 2 as a regression problem.
C. Treat problem 1 as a regression problem, problem 2 as a classification problem.
D. Treat both as regression problems.

通过上述的总结,我们很容易得知问题1为回归问题,问题2为分类问题。

补充笔记
Supervised Learning

In 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.

Supervised learning problems are categorized into “regression” and “classification” problems. In a regression problem, we are trying to predict results within a continues output, meaning that we are trying to map inout 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.

无监督学习(Unsupervised Learning)

在监督学习中,我们回顾一下预测肿瘤的例子,在这个例子中的数据集每个样本都已经被标明为正样本或负样本,即良性肿瘤或恶性肿瘤。因此对于监督学习中的每一个样本,我们已经清楚地告知了什么是所谓的正确答案,即它们是良性还是恶性。

在无监督学习中,我们用的数据会和监督学习中的不一样。在无监督学习中,没有属性或标签这一概念,也就是说所有数据都是一样的,没有区别。所以,在无监督学习中,我们只有一个数据集,它可能判定该数据集包含两个不同的聚类。

如上图所示,无监督学习算法会把这些数据分成两个不同的聚类,这就是所谓的聚类算法。这里我们举一个关于基因芯片的例子说明无监督学习算法和聚类算法在基因组学中的应用。其基本的思想是:给定一组不同的个体,对于每个个体检测它们是否拥有某个特定的基因。即我们要去分析有多少基因显现出来,因此下图中的红、绿和灰色等等颜色,它们展示了这些不同的个体是否拥有一个特定的基因。然后,我们就要通过聚类算法把不同的个体归入不同的类或归为不同类型的人。

在这个例子中,我们没有提前告知这些算法这是第一类人、这是第二类人······,相反我们只是告知算法这里有一堆数据,以及向算法问道“你”能不能将这些数据自动归类,然后算法就自动按得到的类型把这些数据归类整理,这就是无监督学习。

而聚类算法只是无监督学习的一种,现在我们来介绍另一种。按照惯例,我们先举一个例子说明。

鸡尾酒宴问题:假设有一个宴会,有一屋子的人,大家都坐在一起而且都在同时说话。在这种情况下,你很难听清楚你面前的人说的话。因此,我们不妨再做一个假设。假设有一个宴会,屋子里只有两个人,每个人面前都有一个麦克风,两个人同时说话。这时有个无聊的研究人员录下这两人的声音。

鸡尾酒宴问题

当我们打开这段录音时,我们会听到两个人的说话声音。类比于在无监督学习中, 我们将两个人的声音输入,通过某种算法找出其中蕴含的某种分类,将第一个人的声音分离出来,将第二种人的声音分离出来。这种算法就称为鸡尾酒会算法。

这里你可能认为实现这一算法很复杂,但我们推荐使用Octave这款开源的免费软件编写该算法只需一行。

[W,s,v] = svd((repmat(sum(x.*x,1),size(x,1),1).*x)*x');

Question:
Of the following examples, which would you address using an unsupervised learning algorithm?
A. Given email labeled as spam/not spam, learn a spam filter.
B. Given a set of news articles found on the web, group them into set of articles about the same story.
C. Given a database of customer data, automatically discover market segments and group customs into different market segments.
D. Given a dataset of patients diagnosed as either having diabetes or not, learn to classify new patients as having diabetes or not.

A中的例子为监督学习中垃圾邮件过滤的例子,D中的是否患有糖尿病的例子与是否胸部肿瘤是否为恶性的例子一样属于监督学习;B中的新闻分类和C中的市场划分均属于无监督学习。

补充笔记
Unsupervised Learning

Unsupervised learning 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.

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

With unsupervised learning there is no feedback based on the prediction results.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值