使用随机森林作为 adaboost 的基础分类器

using random forest as base classifier with adaboost

我可以使用带有随机森林的 AdaBoost 作为基础分类器吗?我在网上查了下,没有人做。

就像下面的代码;我尝试 运行 但它需要很多时间:

estimators = Pipeline([('vectorizer', CountVectorizer()),
                       ('transformer', TfidfTransformer()),
                       ('classifier', AdaBoostClassifier(learning_rate=1))])

RF=RandomForestClassifier(criterion='entropy',n_estimators=100,max_depth=500,min_samples_split=100,max_leaf_nodes=None,
                          max_features='log2')


param_grid={
    'vectorizer__ngram_range': [(1,2),(1,3)],
    'vectorizer__min_df': [5],
    'vectorizer__max_df': [0.7],
    'vectorizer__max_features': [1500],

    'transformer__use_idf': [True , False],
    'transformer__norm': ('l1','l2'),
    'transformer__smooth_idf': [True , False],
     'transformer__sublinear_tf': [True , False],

    'classifier__base_estimator':[RF],
    'classifier__algorithm': ("SAMME.R","SAMME"),
    'classifier__n_estimators':[4,7,11,13,16,19,22,25,28,31,34,43,50]
}

我尝试使用 GridSearchCV,我将 RF 分类器添加到 AdaBoost 参数中。 如果我使用它,准确性会提高吗?

难怪你实际上没有看到有人这样做 - 这是一个荒谬和糟糕的想法。

您正在尝试构建一个集成 (Adaboost),它本身由集成基础分类器 (RF) 组成——本质上是一个“集成平方”;所以,难怪计算时间长。

但即使它很实用,也有很好的理论上理由去做;引用我自己在 :

中的回答

Adaboost (and similar ensemble methods) were conceived using decision trees as base classifiers (more specifically, decision stumps, i.e. DTs with a depth of only 1); there is good reason why still today, if you don't specify explicitly the base_classifier argument, it assumes a value of DecisionTreeClassifier(max_depth=1). DTs are suitable for such ensembling because they are essentially unstable classifiers, which is not the case with SVMs, hence the latter are not expected to offer much when used as base classifiers.

On top of this, SVMs are computationally much more expensive than decision trees (let alone decision stumps), which is the reason for the long processing times you have observed.

这个论点也适用于 RFs - 它们不是 不稳定的 分类器,因此没有任何理由在将它们用作提升算法的基础分类器时实际期望性能改进,像 Adaboost。

简答: 这并非不可能。 不知道理论上这样做有没有问题,但是我试了一次,准确率提高了。

长答案:

我在具有 n 行 p 个实值特征和长度为 n 的标签列表的典型数据集上进行了尝试。重要的是,它们是通过DeepWalk算法获得的图中节点的嵌入,节点被分为两个类。我使用 5 折交叉验证对这些数据训练了一些分类模型,并测量了它们的常见评估指标(精度、召回率、AUC 等)。我使用的模型是 SVM、逻辑回归、随机森林、2 层感知器和带有随机森林分类器的 Adaboost。最后一个模型,带有随机森林分类器的 Adaboost,产生了最好的结果(95% AUC 相比多层感知器的 89% 和随机森林的 88%)。当然,现在运行时间增加了一个因素,比方说,100,但它仍然是大约 20 分钟,所以这对我来说不是限制。

我是这么想的:首先,我正在使用交叉验证,所以可能没有不为人知的过度拟合。其次,两者都是集成学习方法,但随机森林是一种装袋方法,而Adaboost是一种提升技术。也许它们仍然有足够的不同,以至于它们的组合有意义?