我正在尝试使用 DecisionTreeClassifier(“DTC”)作为 base_estimator 来调整 AdaBoost 分类器(“ABT”)。我想同时调整ABT和 DTC 参数,但不确定如何实现这一点 - 管道不应该工作,因为我没有将 DTC 的输出“管道”到 ABT。这个想法是在 GridSearchCV 估计器中迭代 ABT 和 DTC 的超参数。
如何正确指定调整参数?
我尝试了以下操作,这在下面产生了错误。
[IN]
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import AdaBoostClassifier
from sklearn.grid_search import GridSearchCV
param_grid = {dtc__criterion : ["gini", "entropy"],
dtc__splitter : ["best", "random"],
abc__n_estimators: [none, 1, 2]
}
DTC = DecisionTreeClassifier(random_state = 11, max_features = "auto", class_weight = "auto",max_depth = None)
ABC = AdaBoostClassifier(base_estimator = DTC)
# run grid search
grid_search_ABC = GridSearchCV(ABC, param_grid=param_grid, scoring = 'roc_auc')
[OUT]
ValueError: Invalid parameter dtc for estimator AdaBoostClassifier(algorithm='SAMME.R',
base_estimator=DecisionTreeClassifier(class_weight='auto', criterion='gini', max_depth=None,
max_features='auto', max_leaf_nodes=None, min_samples_leaf=1,
min_samples_split=2, min_weight_fraction_leaf=0.0,
random_state=11, splitter='best'),
learning_rate=1.0, n_estimators=50, random_state=11)