如何防止python XGBClassifier模型中的特性相互作用



我已经训练了这个模型:

model = XGBClassifier( #XGBClassifier
objective='binary:logistic',
base_score=0.5, 
booster='gbtree', 
colsample_bylevel=1,
colsample_bynode=1, 
colsample_bytree=1,
enable_categorical=False, 
gamma=2, 
gpu_id=-1,
importance_type=None, 
interaction_constraints='',
learning_rate=0.1, 
max_delta_step=0,
max_depth=3,
min_child_weight=7, 
monotone_constraints='(1,1,1,1,1)',
n_jobs=1, 
nthread=1, 
num_parallel_tree=1,
predictor='auto',
random_state=0, 
reg_alpha=0, 
reg_lambda=1,
scale_pos_weight=1, 
silent=True, 
subsample=0.8,
tree_method='exact',
validate_parameters=1, 
pred_contribs=True,  
verbose=True)


model.fit(X, Y)

X数据帧具有5个预测功能。有没有办法通过编辑XGB分类器代码中的参数来防止这5个特征相互作用?

如果更改interaction_constraints=[],它将强制这些功能无法交互。

如果你想验证这种情况,你可以通过做一些类似的事情来询问单个树的输出

trees = model.get_booster().get_dump()

然后检查树[0]、树[1]等,你会发现每棵树只能存在一个特性。

最新更新