各种分类算法的比较

时间:2022-11-08 21:14:33

   面试的时候,经常会被问到一些分类算法的优劣比较。看到一些有用的相关文章,总结下来仅供参考:

Source 1. http://sigvc.org/bbs/thread-3323-1-1.html

How do you know what machine learning algorithm to choose for your classification problem? Of course, if you really care about accuracy, your best bet is to test out a couple different ones (making sure to try different parameters within each algorithm as well), and select the best one by cross-validation. But if you’re simply looking for a “good enough” algorithm for your problem, or a place to start, here are some general guidelines I’ve found to work well over the years.

How large is your training set?

If your training set is small, high bias/low variance classifiers (e.g., Naive Bayes) have an advantage over low bias/high variance classifiers (e.g., kNN), since the latter will overfit. But low bias/high variance classifiers start to win out as your training set grows (they have lower asymptotic error), since high bias classifiers aren’t powerful enough to provide accurate models. You can also think of this as a generative model vs. discriminative model distinction.

Advantages of some particular algorithms

Advantages of Naive Bayes:   Super simple, you’re just doing a bunch of counts. If the NB conditional independence assumption actually holds, a Naive Bayes classifier will converge quicker than discriminative models like logistic regression, so you need less training data. And even if the NB assumption doesn’t hold, a NB classifier still often does a great job in practice. A good bet if want something fast and easy that performs pretty well. Its main disadvantage is that it can’t learn interactions between features (e.g., it can’t learn that although you love movies with Brad Pitt and Tom Cruise, you hate movies where they’re together).

Advantages of Logistic Regression:   Lots of ways to regularize your model, and you don’t have to worry as much about your features being correlated, like you do in Naive Bayes. You also have a nice probabilistic interpretation, unlike decision trees or SVMs, and you can easily update your model to take in new data (using an online gradient descent method), again unlike decision trees or SVMs. Use it if you want a probabilistic framework (e.g., to easily adjust classification thresholds, to say when you’re unsure, or to get confidence intervals) or if you expect to receive more training data in the future that you want to be able to quickly incorporate into your model.

Advantages of Decision Trees:   Easy to interpret and explain (for some people – I’m not sure I fall into this camp). They easily handle feature interactions and they’re non-parametric, so you don’t have to worry about outliers or whether the data is linearly separable (e.g., decision trees easily take care of cases where you have class A at the low end of some feature x, class B in the mid-range of feature x, and A again at the high end). One disadvantage is that they don’t support online learning, so you have to rebuild your tree when new examples come on. Another disadvantage is that they easily overfit, but that’s where ensemble methods like random forests (or boosted trees) come in. Plus, random forests are often the winner for lots of problems in classification (usually slightly ahead of SVMs, I believe), they’re fast and scalable, and you don’t have to worry about tuning a bunch of parameters like you do with SVMs, so they seem to be quite popular these days.

Advantages of SVMs:   High accuracy, nice theoretical guarantees regarding overfitting, and with an appropriate kernel they can work well even if you’re data isn’t linearly separable in the base feature space. Especially popular in text classification problems where very high-dimensional spaces are the norm. Memory-intensive, hard to interpret, and kind of annoying to run and tune, though, so I think random forests are starting to steal the crown.

Recall, though, that better data often beats better algorithms, and designing good features goes a long way. And if you have a huge dataset, then whichever classification algorithm you use might not matter so much in terms of classification performance (so choose your algorithm based on speed or ease of use instead).

And to reiterate what I said above, if you really care about accuracy, you should definitely try a bunch of different classifiers and select the best one by cross-validation. Or, to take a lesson from the Netflix Prize (and Middle Earth), just use an ensemble method to choose them all.

Source 2. http://bbs.pinggu.org/thread-2604496-1-1.html

1决策树(Decision Trees)的优缺点

决策树的优点:

一、 决策树易于理解和解释.人们在通过解释后都有能力去理解决策树所表达的意义。

二、 对于决策树,数据的准备往往是简单或者是不必要的.其他的技术往往要求先把数据一般化,比如去掉多余的或者空白的属性。

三、 能够同时处理数据型和常规型属性。其他的技术往往要求数据属性的单一。

四、 决策树是一个白盒模型。如果给定一个观察的模型,那么根据所产生的决策树很容易推出相应的逻辑表达式。

五、 易于通过静态测试来对模型进行评测。表示有可能测量该模型的可信度。

六、 在相对短的时间内能够对大型数据源做出可行且效果良好的结果。

七、 可以对有许多属性的数据集构造决策树。

八、 决策树可很好地扩展到大型数据库中,同时它的大小独立于数据库的大小。

决策树的缺点:

一、 对于那些各类别样本数量不一致的数据,在决策树当中,信息增益的结果偏向于那些具有更多数值的特征。

二、 决策树处理缺失数据时的困难。

三、 过度拟合问题的出现。

四、 忽略数据集中属性之间的相关性。


2 人工神经网络的优缺点

人工神经网络的优点:分类的准确度高,并行分布处理能力强,分布存储及学习能力强,对噪声神经有较强的鲁棒性和容错能力,能充分逼近复杂的非线性关系,具备联想记忆的功能等。

人工神经网络的缺点:神经网络需要大量的参数,如网络拓扑结构、权值和阈值的初始值;不能观察之间的学习过程,输出结果难以解释,会影响到结果的可信度和可接受程度;学习时间过长,甚至可能达不到学习的目的。


3 KNN算法(K-Nearest Neighbour) 的优缺点

KNN算法的优点:

一、简单、有效。

二、重新训练的代价较低(类别体系的变化和训练集的变化,在Web环境和电子商务应用中是很常见的)。

三、计算时间和空间线性于训练集的规模(在一些场合不算太大)。

四、 由于KNN方法主要靠周围有限的邻近的样本,而不是靠判别类域的方法来确定所属类别的,因此对于类域的交叉或重叠较多的待分样本集来说,KNN方法较其他方法更为适合。

五、 该算法比较适用于样本容量比较大的类域的自动分类,而那些样本容量较小的类域采用这种算法比较容易产生误分。

KNN算法缺点:

一、 KNN算法是懒散学习方法(lazy learning,基本上不学习),一些积极学习的算法要快很多。

二、 类别评分不是规格化的(不像概率评分)。

三、 输出的可解释性不强,例如决策树的可解释性较强。

四、 该算法在分类时有个主要的不足是,当样本不平衡时,如一个类的样本容量很大,而其他类样本容量很小时,有可能导致当输入一个新样本时,该样本的K个邻居中大容量类的样本占多数。该算法只计算“最近的”邻居样本,某一类的样本数量很大,那么或者这类样本并不接近目标样本,或者这类样本很靠近目标样本。无论怎样,数量并不能影响运行结果。可以采用权值的方法(和该样本距离小的邻居权值大)来改进。

五、 计算量较大。目前常用的解决方法是事先对已知样本点进行剪辑,事先去除对分类作用不大的样本。


4 支持向量机(SVM)的优缺点

SVM的优点:

一、 可以解决小样本情况下的机器学习问题。

二、 可以提高泛化性能。

三、 可以解决高维问题。

四、 可以解决非线性问题。

五、 可以避免神经网络结构选择和局部极小点问题。

SVM的缺点:

一、 对缺失数据敏感。

二、 对非线性问题没有通用解决方案,必须谨慎选择Kernelfunction来处理。


5 朴素贝叶斯的优缺点

优点:

一、 朴素贝叶斯模型发源于古典数学理论,有着坚实的数学基础,以及稳定的分类效率。

二、 NBC模型所需估计的参数很少,对缺失数据不太敏感,算法也比较简单。

缺点:

一、 理论上,NBC模型与其他分类方法相比具有最小的误差率。但是实际上并非总是如此,这是因为NBC模型假设属性之间相互独立,这个假设在实际应用中往往是不成立的(可以考虑用聚类算法先将相关性较大的属性聚类),这给NBC模型的正确分类带来了一定影响。在属性个数比较多或者属性之间相关性较大时,NBC模型的分类效率比不上决策树模型。而在属性相关性较小时,NBC模型的性能最为良好。

二、 需要知道先验概率。

三、 分类决策存在错误率


6 Adaboosting方法的优点

一、 adaboost是一种有很高精度的分类器。

二、 可以使用各种方法构建子分类器,Adaboost算法提供的是框架。

三、 当使用简单分类器时,计算出的结果是可以理解的。而且弱分类器构造极其简单。

四、 简单,不用做特征筛选。

五、 不用担心overfitting。