轻松看懂机器学习十大常用算法
每个算法都看了好几个视频,挑出讲的最清晰明了有趣的,便于科普。
以后有时间再对单个算法做深入地解析。
今天的算法如下:
决策树
随机森林算法
逻辑回归
SVM
朴素贝叶斯
K最近邻算法
K均值算法
Adaboost 算法
神经网络
马尔可夫
1. 决策树
根据一些 feature 进行分类,每个节点提一个问题,通过判断,将数据分为两类,再继续提问。这些问题是根据已有数据学习出来的,再投入新数据的时候,就可以根据这棵树上的问题,将数据划分到合适的叶子上。

2. 随机森林
在源数据中随机选取数据,组成几个子集

S 矩阵是源数据,有 1-N 条数据,A B C 是feature,最后一列C是类别

由 S 随机生成 M 个子矩阵

这 M 个子集得到 M 个决策树
将新数据投入到这 M 个树中,得到 M 个分类结果,计数看预测成哪一类的数目最多,就将此类别作为最后的预测结果

3. 逻辑回归
当预测目标是概率这样的,值域需要满足大于等于0,小于等于1的,这个时候单纯的线性模型是做不到的,因为在定义域不在某个范围之内时,值域也超出了规定区间。

所以此时需要这样的形状的模型会比较好

那么怎么得到这样的模型呢?
这个模型需要满足两个条件 大于等于0,小于等于1
大于等于0 的模型可以选择 绝对值,平方值,这里用 指数函数,一定大于0
小于等于1 用除法,分子是自己,分母是自身加上1,那一定是小于1的了

再做一下变形,就得到了 logistic regression 模型

通过源数据计算可以得到相应的系数了

最后得到 logistic 的图形

4. SVM
support vector machine
要将两类分开,想要得到一个超平面,最优的超平面是到两类的 margin 达到最大,margin就是超平面与离它最近一点的距离,如下图,Z2>Z1,所以绿色的超平面比较好

将这个超平面表示成一个线性方程,在线上方的一类,都大于等于1,另一类小于等于-1

点到面的距离根据图中的公式计算

所以得到 total margin 的表达式如下,目标是最大化这个 margin,就需要最小化分母,于是变成了一个优化问题

举个栗子,三个点,找到最优的超平面,定义了 weight vector=(2,3)-(1,1)

得到 weight vector 为(a,2a),将两个点代入方程,代入(2,3)另其值=1,代入(1,1)另其值=-1,求解出 a 和 截矩 w0 的值,进而得到超平面的表达式。

a 求出来后,代入(a,2a)得到的就是 support vector
a 和 w0 代入超平面的方程就是 support vector machine
5. 朴素贝叶斯
举个在 NLP 的应用
给一段文字,返回情感分类,这段文字的态度是positive,还是negative

为了解决这个问题,可以只看其中的一些单词

这段文字,将仅由一些单词和它们的计数代表

原始问题是:给你一句话,它属于哪一类
通过 bayes rules 变成一个比较简单容易求得的问题

问题变成,这一类中这句话出现的概率是多少,当然,别忘了公式里的另外两个概率
栗子:单词 love 在 positive 的情况下出现的概率是 0.1,在 negative 的情况下出现的概率是 0.001


时间:2018-10-09 22:49 来源: 转发量:次
声明:本站部分作品是由网友自主投稿和发布、编辑整理上传,对此类作品本站仅提供交流平台,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,不为其版权负责。如果您发现网站上有侵犯您的知识产权的作品,请与我们取得联系,我们会及时修改或删除。
相关文章:
相关推荐:
网友评论: