Machine learning algorithms: 6 common classical methods

A brief overview of classic representative of machine learning methods. These methods are the focus of ideological connotation.

01 regression algorithm

Most machine learning courses, regression algorithms are presented the first algorithm. There are two reasons: a regression algorithm is relatively simple, it can introduce people to a smooth migration from statistical machine learning. The two return algorithm is the cornerstone of a number of powerful algorithms behind, if you do not understand regression algorithm, can not learn those powerful algorithms. Regression algorithm has two important sub-categories: namely linear regression and logistic regression.

Linear regression is what we said before prices solving problems. How to fit a straight line best match all my data? Generally use the "least squares method" to solve. Thinking "least squares method" is such that, assuming that the true value of our fitted straight line representing the data, and the observed data represents values ​​have errors. In order to reduce the influence of errors as much as possible, so that the need to solve a linear minimum square sum of all errors. The optimal method of least squares problem and minimize the function extreme problem. Function extreme mathematically we will generally adopt the derivative is 0 method. But this approach is not suitable computer, you may not come out to solve, it may be too large amount of calculation.

Computer science has created a specialized discipline called "numerical", designed to improve the accuracy and efficiency of the computer problems of all kinds of calculations. For example, the famous "gradient descent" and "Newton's Law" is the classic numerical algorithm, it is also well suited to deal with the problem solving function extreme. Gradient descent is one of the regression model to solve the most simple and effective method. Strictly speaking, due later in the neural network and recommendation algorithms have linear regression factors, so gradient descent algorithm in the back also has applications.

Logistic regression is a linear regression algorithm is very similar, but, in essence, the question of the type of linear regression and logistic regression process is inconsistent. Linear regression process is a numerical problem , which is the last number is the predicted result such rates. The logistic regression algorithm of the class, that is, logistic regression to predict the result is a discrete classification , for example, to determine whether this message is spam, and whether the user will click on the ad, and so on.

Implementing aspects of it, just logistic regression results of the linear regression added a Sigmoid function, numerical results into probability between 0 and 1 for (the image Sigmoid function is generally not intuitive, you only need to understand the larger the value, the more the function approaches 1, the smaller the value, the function approximation 0), then we can do predicted based on this probability, a probability greater than 0.5, then this message is spam, or the like whether the tumor is malignant. Intuitively, a logistic regression is to draw a line classification, see below.

The intuition logistic regression

Suppose we have a set of data tumor patients, these patients in some tumors (blue dot in the figure) benign, some (red dot in the figure) malignant. Red and blue where a tumor can be referred to as "tag" data. While each data includes two "features": age, tumor size and patient. We label these two features are mapped onto the two-dimensional space, the formation of the data on my map.

When I have a green point, I judge that the tumor is malignant or benign it? According red and blue dot we trained a logistic regression model, which is the figure of the sorting line. At this time, according to the classification green dot appears to the left of the line, so we judge its label should be red, that are malignant.

Logistic regression algorithm to draw free lines are basically linear (non-linear classification also draw lines logistic regression, but that kind of model is inefficient when dealing with large amounts of data), which means that when two types of the boundaries between time is not linear, logistic regression of skills insufficient. The following two machine learning algorithm is the most powerful and important algorithms, we can fit a non-linear classification line.

02 Neural Networks

神经网络(也称之为人工神经网络,ANN)算法是80年代机器学习界非常流行的算法,不过在90年代中途衰落。现在,携着“深度学习”之势,神经网络重装归来,重新成为最强大的机器学习算法之一。

神经网络的诞生起源于对大脑工作机理的研究。早期生物界学者们使用神经网络来模拟大脑。机器学习的学者们使用神经网络进行机器学习的实验,发现在视觉与语音的识别上效果都相当好。在BP算法(加速神经网络训练过程的数值算法)诞生以后,神经网络的发展进入了一个热潮。BP算法的发明人之一是前面介绍的机器学习大牛Geoffrey Hinton(图1中的中间者)。

具体说来,神经网络的学习机理是什么?简单来说,
就是分解与整合。在著名的Hubel-Wiesel试验中,学者们研究猫的视觉分析机理是这样的。

Hubel-Wiesel试验与大脑视觉机理

比方说,一个正方形,分解为四个折线进入视觉处理的下一层中。四个神经元分别处理一个折线。每个折线再继续被分解为两条直线,每条直线再被分解为黑白两个面。于是,一个复杂的图像变成了大量的细节进入神经元,神经元处理以后再进行整合,最后得出了看到的是正方形的结论。这就是大脑视觉识别的机理,也是神经网络工作的机理。

让我们看一个简单的神经网络的逻辑架构。在这个网络中,分成
输入层,隐藏层,和输出层输入层负责接收信号,隐藏层负责对数据的分解与处理,最后的结果被整合到输出层。每层中的一个圆代表一个处理单元,可以认为是模拟了一个神经元,若干个处理单元组成了一个层,若干个层再组成了一个网络,也就是"神经网络"。


神经网络的逻辑架构

在神经网络中,每个处理单元事实上就是一个逻辑回归模型,逻辑回归模型接收上层的输入,把模型的预测结果作为输出传输到下一个层次。通过这样的过程,经网络可以完成非常复杂的非线性分类。

下图会演示神经网络在图像识别领域的一个著名应用,这个程序叫做LeNet,是一个基于多个隐层构建的神经网络。通过LeNet可以识别多种手写数字,并且达到很高的识别精度与拥有较好的鲁棒性。

                             

 

LeNet的效果展示

右下方的方形中显示的是输入计算机的图像,方形上方的红色字样“answer”后面显示的是计算机的输出。左边的三条竖直的图像列显示的是神经网络中三个隐藏层的输出,可以看出,随着层次的不断深入,越深的层次处理的细节越低,例如层3基本处理的都已经是线的细节了。LeNet的发明人就是前文介绍过的机器学习的大牛Yann LeCun(图1右者)。

进入90年代,神经网络的发展进入了一个瓶颈期。其主要原因是尽管有BP算法的加速,神经网络的训练过程仍然很困难。因此90年代后期支持向量机(SVM)算法取代了神经网络的地位。

03 SVM(支持向量机)

支持向量机算法是诞生于统计学习界,同时在机器学习界大放光彩的经典算法。

支持向量机算法从某种意义上来说是逻辑回归算法的强化:通过给予逻辑回归算法更严格的优化条件,支持向量机算法可以获得比逻辑回归更好的分类界线。但是如果没有某类函数技术,则支持向量机算法最多算是一种更好的线性分类技术。

但是,通过跟高斯“核”的结合,支持向量机可以表达出非常复杂的分类界线,从而达成很好的的分类效果。“核”事实上就是一种特殊的函数,最典型的特征就是可以将低维的空间映射到高维的空间。

例如下图所示:

                                                                

支持向量机图例

我们如何在二维平面划分出一个圆形的分类界线?在二维平面可能会很困难,但是通过“核”可以将二维空间映射到三维空间,然后使用一个线性平面就可以达成类似效果。也就是说,二维平面划分出的非线性分类界线可以等价于三维平面的线性分类界线。于是,我们可以通过在三维空间中进行简单的线性划分就可以达到在二维平面中的非线性划分效果。

          

三维空间的切割

支持向量机是一种数学成分很浓的机器学习算法(相对的,神经网络则有生物科学成分)。在算法的核心步骤中,有一步证明,即将数据从低维映射到高维不会带来最后计算复杂性的提升。于是,通过支持向量机算法,既可以保持计算效率,又可以获得非常好的分类效果。因此支持向量机在90年代后期一直占据着机器学习中最核心的地位,基本取代了神经网络算法。直到现在神经网络借着深度学习重新兴起,两者之间才又发生了微妙的平衡转变。

04 聚类算法

前面的算法中的一个显著特征就是我的训练数据中包含了标签,训练出的模型可以对其他未知数据预测标签。在下面的算法中,训练数据都是不含标签的,而算法的目的则是通过训练,推测出这些数据的标签。这类算法有一个统称,即无监督算法(前面有标签的数据的算法则是有监督算法)。无监督算法中最典型的代表就是聚类算法。

让我们还是拿一个二维的数据来说,某一个数据包含两个特征。我希望通过聚类算法,给他们中不同的种类打上标签,我该怎么做呢?简单来说,
聚类算法就是计算种群中的距离,根据距离的远近将数据划分为多个族群。


聚类算法中最典型的代表就是K-Means算法。

05 降维算法

降维算法也是一种无监督学习算法,其主要特征是将数据从高维降低到低维层次。在这里,维度其实表示的是数据的特征量的大小,例如,房价包含房子的长、宽、面积与房间数量四个特征,也就是维度为4维的数据可以看出来,长与宽事实上与面积表示的信息重叠了,例如面积=长 × 宽。通过降维算法我们就可以去除冗余信息,将特征减少为面积与房间数量两个特征,即从4维的数据压缩到2维。于是我们将数据从高维降低到低维,不仅利于表示,同时在计算上也能带来加速。

刚才说的降维过程中减少的维度属于肉眼可视的层次,同时压缩也不会带来信息的损失(因为信息冗余了)。如果肉眼不可视,或者没有冗余的特征,降维算法也能工作,不过这样会带来一些信息的损失。但是,降维算法可以从数学上证明,从高维压缩到的低维中最大程度地保留了数据的信息。因此,使用降维算法仍然有很多的好处。

降维算法的主要作用是压缩数据与提升机器学习其他算法的效率。通过降维算法,可以将具有几千个特征的数据压缩至若干个特征。另外,降维算法的另一个好处是数据的可视化,例如将5维的数据压缩至2维,然后可以用二维平面来可视。降维算法的主要代表是PCA算法(即主成分分析算法)。

06 推荐算法

推荐算法是目前业界非常火的一种算法,在电商界,如亚马逊,天猫,京东等得到了广泛的运用。推荐算法的主要特征就是可以自动向用户推荐他们最感兴趣的东西,从而增加购买率,提升效益。推荐算法有两个主要的类别:

一类是基于物品内容的推荐,是将与用户购买的内容近似的物品推荐给用户,这样的前提是每个物品都得有若干个标签,因此才可以找出与用户购买物品类似的物品,这样推荐的好处是关联程度较大,但是由于每个物品都需要贴标签,因此工作量较大。

另一类是基于用户相似度的推荐,则是将与目标用户兴趣相同的其他用户购买的东西推荐给目标用户,例如小A历史上买了物品B和C,经过算法分析,发现另一个与小A近似的用户小D购买了物品E,于是将物品E推荐给小A。

两类推荐都有各自的优缺点,在一般的电商应用中,一般是两类混合使用。推荐算法中最有名的算法就是协同过滤算法。

07 其他

除了以上算法之外,机器学习界还有其他的如高斯判别,朴素贝叶斯,决策树等等算法。但是上面列的六个算法是使用最多,影响最广,种类最全的典型。机器学习界的一个特色就是算法众多,发展百花齐放。

下面做一个总结,按照训练的数据有无标签,可以将上面算法分为监督学习算法和无监督学习算法,但推荐算法较为特殊,既不属于监督学习,也不属于非监督学习,是单独的一类。

监督学习算法:线性回归,逻辑回归,神经网络,SVM

无监督学习算法:聚类算法,降维算法

特殊算法:

推荐算法

除了这些算法以外,有一些算法的名字在机器学习领域中也经常出现。但他们本身并不算是一个机器学习算法,而是为了解决某个子问题而诞生的。你可以理解他们为以上算法的子算法,用于大幅度提高训练过程。其中的代表有:梯度下降法,主要运用在线型回归,逻辑回归,神经网络,推荐算法中;牛顿法,主要运用在线型回归中;BP算法,主要运用在神经网络中;SMO算法,主要运用在SVM中。

End.

来源:CSDN

零基础学 Python(送价值109的视频课),来这里
 只需7天时间,跨进Python编程大门,已有3800+加入

【基础】0基础入门python,24小时有人快速解答问题;
【提高】40多个项目实战,老手可以从真实场景中学习python;
【直播】不定期直播项目案例讲解,手把手教你如何分析项目;
【分享】优质python学习资料分享,让你在最短时间获得有价值的学习资源;圈友优质资料或学习分享,会不时给予赞赏支持,希望每个优质圈友既能赚回加入费用,也能快速成长,并享受分享与帮助他人的乐趣。
【人脉】收获一群志同道合的朋友,并且都是python从业者
【价格】本着布道思想,只需 69元 加入一个能保证学习效果的良心圈子。
【赠予】价值109元 0基础入门在线课程,免费送给圈友们,供巩固和系统化复习

发布了88 篇原创文章 · 获赞 18 · 访问量 11万+

Guess you like

Origin blog.csdn.net/lovenankai/article/details/104404379