假设我在处理一些分类问题。(欺诈检测和评论垃圾邮件是我目前正在处理的两个问题,但我对一般的分类任务很好奇。)
我如何知道我应该使用哪个分类器?
决策树
支持向量机
贝叶斯
神经网络
再邻居
q学习的
遗传算法
马尔可夫决策过程
卷积神经网络
线性回归或逻辑回归
提升,装袋,取样
随机爬坡或模拟退火
...
在哪些情况下,其中一个是“自然的”第一选择,选择它的原则是什么?
我正在寻找的答案类型的例子(来自Manning等人的信息检索介绍书):
a.如果你的数据被标记了,但你只有有限的数量,你应该使用高偏差的分类器(例如,朴素贝叶斯)。
我猜这是因为高偏差分类器会有更低的方差,这是很好的,因为数据量小。
b.如果你有大量的数据,那么分类器真的不那么重要,所以你可能应该选择一个具有良好可扩展性的分类器。
其他指导方针是什么?甚至像“如果你必须向一些高层管理人员解释你的模型,那么也许你应该使用决策树,因为决策规则是相当透明的”这样的回答也是很好的。不过,我不太关心实现/库问题。
另外,对于一个有点独立的问题,除了标准的贝叶斯分类器,是否有“标准的最先进的”方法来检测评论垃圾邮件(而不是电子邮件垃圾邮件)?
使用交叉验证的模型选择可能是您所需要的。
交叉验证
你要做的就是简单地把你的数据集分成k个不重叠的子集(折叠),用k-1次折叠来训练一个模型,并用你遗漏的折叠来预测它的性能。对每一种可能的折叠组合都要这样做(首先保留第1次折叠,然后是第2次,……,然后是k,用剩下的折叠进行训练)。完成后,估计所有折叠的平均性能(也可能是性能的方差/标准偏差)。
如何选择参数k取决于你拥有的时间。k的通常值是3、5、10甚至N,其中N是数据的大小(这与省略一个交叉验证相同)。我更喜欢5到10个。
模型选择
假设你有5个方法(ANN, SVM, KNN等)和每个方法的10个参数组合(取决于方法)。您只需对每种方法和参数组合(5 * 10 = 50)进行交叉验证,并选择最佳模型、方法和参数。然后你用最好的方法和参数重新训练所有的数据,你就有了最终的模型。
我还有话要说。例如,如果您为每个方法和参数组合使用了许多方法和参数,则很可能会过度拟合。在这种情况下,必须使用嵌套交叉验证。
嵌套交叉验证
在嵌套交叉验证中,对模型选择算法执行交叉验证。
Again, you first split your data into k folds. After each step, you choose k-1 as your training data and the remaining one as your test data. Then you run model selection (the procedure I explained above) for each possible combination of those k folds. After finishing this, you will have k models, one for each combination of folds. After that, you test each model with the remaining test data and choose the best one. Again, after having the last model you train a new one with the same method and parameters on all the data you have. That's your final model.
当然,这些方法还有很多变体,还有其他我没有提到的东西。如果你需要更多关于这些的信息,找一些关于这些主题的出版物。
正如Andrew Ng教授经常说的那样:总是从实现一个粗糙的、肮脏的算法开始,然后迭代地完善它。
For classification, Naive Bayes is a good starter, as it has good performances, is highly scalable and can adapt to almost any kind of classification task. Also 1NN (K-Nearest Neighbours with only 1 neighbour) is a no-hassle best fit algorithm (because the data will be the model, and thus you don't have to care about the dimensionality fit of your decision boundary), the only issue is the computation cost (quadratic because you need to compute the distance matrix, so it may not be a good fit for high dimensional data).
Another good starter algorithm is the Random Forests (composed of decision trees), this is highly scalable to any number of dimensions and has generally quite acceptable performances. Then finally, there are genetic algorithms, which scale admirably well to any dimension and any data with minimal knowledge of the data itself, with the most minimal and simplest implementation being the microbial genetic algorithm (only one line of C code! by Inman Harvey in 1996), and one of the most complex being CMA-ES and MOGA/e-MOEA.
记住,通常情况下,在真正尝试算法之前,你无法真正知道什么对你的数据最有效。
作为一个边注,如果你想要一个理论框架来测试给定问题的假设和算法的理论性能,你可以使用PAC(可能大致正确)学习框架(注意:它非常抽象和复杂!),但总的来说,PAC学习的要点是你应该使用不太复杂,但足够复杂(复杂性是算法可以适合的最大维度)的算法来适合你的数据。换句话说,使用奥卡姆剃刀。