为什么随机森林总是给出 1.0 的预测分数?
Why random forest always give 1.0 prediction score?
我正在尝试测试以下分类器的预测分数:
- random forest
- k neighbors
- svm
- naïve bayes
我没有使用特征选择或特征缩放(根本没有预处理)。
我正在使用如下训练测试拆分:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3)
我测试了几个数据集(来自sklearn
):
- load_iris
- load_breast_cancer
- load_wine
在所有这 3 个中,随机森林总是给出完美的预测(测试精度 1.0)。
我尝试创建用于分类的随机样本:
make_classification(flip_y=0.3, weights = [0.65, 0.35], n_features=40, n_redundant=4, n_informative=36,n_classes=2,n_clusters_per_class=1, n_samples=50000)
随机森林再次在测试集上给出了完美的预测(准确度 1.0)。
所有其他分类器在测试集上的表现都很好 (0.8-0.97),但不如随机森林那么完美 (1.0)。
- 我错过了什么?
- 随机森林真的以完美的方式胜过所有其他分类器吗?
关于 1.0 的完美准确度分数,我们必须记住,所有这 3 个数据集现在都被认为是玩具数据集,scikit-learn 生成的人工数据可能也是如此。 s make_classification
.
也就是说,RF 确实被认为是一种非常 强大的分类算法。甚至还有一篇相对较新的(2014 年)论文,标题为 Do we Need Hundreds of Classifiers to Solve Real World Classification Problems?,其结论是(引用摘要,强调原文):
We evaluate 179 classifiers arising from 17 families (discriminant analysis, Bayesian, neural networks, support vector machines, decision trees, rule-based classifiers, boosting, bagging, stacking, random forests and other ensembles, generalized linear models, nearest-neighbors, partial least squares and principal component regression, logistic and multinomial regression, multiple adaptive regression splines and other methods) [...] We use 121 data sets, which represent the whole UCI data base [...] The classifiers most likely to be the bests are the random forest (RF) versions
尽管这篇论文受到了一些批评,主要是因为它 did not include boosted trees (but not only for that, see also Are Random Forests Truly the Best Classifiers?),但事实是,至少在 "traditional"、pre-deep 学习分类方面,有已经有说法当有疑问时,试试 RF,上面提到的第一篇论文强化了这一说法。
我正在尝试测试以下分类器的预测分数:
- random forest
- k neighbors
- svm
- naïve bayes
我没有使用特征选择或特征缩放(根本没有预处理)。
我正在使用如下训练测试拆分:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3)
我测试了几个数据集(来自sklearn
):
- load_iris
- load_breast_cancer
- load_wine
在所有这 3 个中,随机森林总是给出完美的预测(测试精度 1.0)。
我尝试创建用于分类的随机样本:
make_classification(flip_y=0.3, weights = [0.65, 0.35], n_features=40, n_redundant=4, n_informative=36,n_classes=2,n_clusters_per_class=1, n_samples=50000)
随机森林再次在测试集上给出了完美的预测(准确度 1.0)。
所有其他分类器在测试集上的表现都很好 (0.8-0.97),但不如随机森林那么完美 (1.0)。
- 我错过了什么?
- 随机森林真的以完美的方式胜过所有其他分类器吗?
关于 1.0 的完美准确度分数,我们必须记住,所有这 3 个数据集现在都被认为是玩具数据集,scikit-learn 生成的人工数据可能也是如此。 s make_classification
.
也就是说,RF 确实被认为是一种非常 强大的分类算法。甚至还有一篇相对较新的(2014 年)论文,标题为 Do we Need Hundreds of Classifiers to Solve Real World Classification Problems?,其结论是(引用摘要,强调原文):
We evaluate 179 classifiers arising from 17 families (discriminant analysis, Bayesian, neural networks, support vector machines, decision trees, rule-based classifiers, boosting, bagging, stacking, random forests and other ensembles, generalized linear models, nearest-neighbors, partial least squares and principal component regression, logistic and multinomial regression, multiple adaptive regression splines and other methods) [...] We use 121 data sets, which represent the whole UCI data base [...] The classifiers most likely to be the bests are the random forest (RF) versions
尽管这篇论文受到了一些批评,主要是因为它 did not include boosted trees (but not only for that, see also Are Random Forests Truly the Best Classifiers?),但事实是,至少在 "traditional"、pre-deep 学习分类方面,有已经有说法当有疑问时,试试 RF,上面提到的第一篇论文强化了这一说法。