使用 SVM 基分类器的 AdaBoost 的执行时间 [英] Execution time of AdaBoost with SVM base classifier

查看:85
本文介绍了使用 SVM 基分类器的 AdaBoost 的执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用这些参数制作了一个Adaboost分类器,

1. n_estimators = 50

2. base_estimator = svc (支持向量分类器)

3. learning_rate = 1

这是我的代码:

从sklearn.ensemble

 导入AdaBoostClassifier从sklearn.svm导入SVCsvc = SVC(内核='线性',概率= True)ABC = AdaBoostClassifier(n_estimators = 50,base_estimator = svc,learning_rate = 1)ABC.fit(X,Y) 

数据集具有18个自变量,而1个分类因变量数据集具有10480个数据点

每次运行此命令都将花费很多时间,但没有任何结果.

有什么方法可以检查执行时间?或有更好的方法可以做到这一点?

解决方案

在实践中,我们从不使用SVM作为Adaboost的基本分类器.

使用决策树作为基本分类器(更具体地说,决策树桩,即深度仅为1的DT),构想了Adaboost(和类似的集成方法);今天有充分的理由说明为什么,如果您未明确指定 base_classifier 参数,则该参数将假定 DecisionTreeClassifier(max_depth = 1)的值.DT很适合此类集合,因为它们本质上是不稳定分类器,而SVM则不是这种分类器,因此,在用作基本分类器时,预计不会提供很多.

最重要的是,SVM在计算上比决策树(更不用说决策 stumps )要昂贵得多,这就是您观察到处理时间长的原因.

除非您有非常个充分理由将SVM用作基本分类器(并且我非常怀疑您这样做),请删除 base_estimator = svc 以便还原设置为默认设置,很可能您会没事的.

I just made a Adaboost Classifier with these parameters,

1.n_estimators = 50

2.base_estimator = svc (support vector classifier)

3.learning_rate = 1

here is my code:

from sklearn.ensemble import AdaBoostClassifier
from sklearn.svm import SVC

svc = SVC(kernel = 'linear',probability = True)

ABC = AdaBoostClassifier(n_estimators = 50, base_estimator = svc, learning_rate = 1)

ABC.fit(X,Y)

Dataset has 18 independent variables and 1 categorical dependent variable dataset has 10480 datapoints

whenever i run this it will take so much time but no any result.

Is there any way to check execution time? Or any better way to do this?

解决方案

In practice, we never use SVMs as base classifiers for Adaboost.

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.

Unless you have a very good reason to stick to SVMs as base classifiers (and I highly doubt that you do), remove the base_estimator = svc in order to revert to the default setting, and most probably you will be fine.

这篇关于使用 SVM 基分类器的 AdaBoost 的执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆