LogitBoost要求基本估计量为回归量

时间:2019-01-06 07:50:40

标签: python classification ensemble-learning boosting

我有一个数据集,每个功能的所有值都是数字,甚至是class / label列。在以python实现的增强算法(例如logitboost,adaboost,gradientboosting)中,除了预设的基本估计量(或弱学习者,迭代我们的数据的模型)以外,我们可以指定分类算法,例如SVM中的SVC,朴素贝叶斯等。上。 (某些算法/程序包(例如xgboost和catboost)是在python中实现的,除了在程序包中实现的算法/程序包之外,不能接受其他任何基本估计量...也许是实现偏好?)

通过介绍,我提出了我的问题。此处的代码无效,并显示以下错误:LogitBoost requires the base estimator to be a regressor.

for j in range(1, 21):
for i in range(1, 11):
    X_train = pd.read_csv('{}-train{}-1.csv'.format(j, i))
    y_train = pd.read_csv('{}-train{}-2.csv'.format(j, i))
    X_test = pd.read_csv('{}-test{}-1.csv'.format(j, i))
    y_test = pd.read_csv('{}-test{}-2.csv'.format(j, i))
    model = logitboost.LogitBoost(base_estimator = svm.SVC())
    model.fit(X_train, y_train)
    y_predict = model.predict(X_test)
    accuracy = metrics.accuracy_score(y_test, y_predict)
    print('Accuracy for dataset {}, segment {} is: '.format(j, i), accuracy)
    print('Confusion Matrix for Datatset {}, segment {} is: '.format(j, i))
    print(metrics.confusion_matrix(y_test, y_predict))

请不要介意缩进。这里显示错误,但是闲置时是正确的。我为此表示歉意。

该行:

model = logitboost.LogitBoost(base_estimator = svm.SVC())

不能与SVC一起使用,应该使用SVC,因为logitboost是一种分类算法。但是,它确实支持SVR(支持向量回归),这不是我想要的。谁能解释为什么会发生这种情况以及我该如何解决?为了比较起见,我需要为每个算法使用相同的基本估计量...

谢谢。

1 个答案:

答案 0 :(得分:0)

这是LogitBoost(和GBM)的工作方式。每个其他弱学习者都适合残差,因此需要成为回归者。 (在LogitBoost中,所有样本的初始预测似乎仅为0.5。我认为其他实现可能会取平均响应。)

documentation

  

base_estimator:object, optional
  的基本估计量   LogitBoost分类器已构建。这应该是 regressor 。如果不   指定base_estimator,使用决策树桩。

Adaboost的不同之处在于,它会更改分类错误的样本的权重,但每个新的弱学习者仍然适合原始数据,分类器也是如此。