如何在 XGBoost 分类器中执行 tree_method ='exact'?

数据挖掘 机器学习 Python xgboost 集成建模
2022-03-12 16:51:00

我正在对一个巨大的数据集及其显示进行 XGBoost 分类:

Tree method is automatically selected to be 'approx' for faster speed. to use old behavior(exact greedy algorithm on single machine), set tree_method to 'exact'

我怎样才能把它改成准确的?

我试过clf = xgb(tree_method='exact')了,它返回错误!

1个回答

Indeedtree_method是 Tree Booster 的一个参数。有 4 个选项,auto默认设置为根据数据集的大小启发式地选择更快的算法。由于您的数据集很大,因此在您的情况下选择了近似算法 ( )。exactapproxhistautoapprox

要更改树构造算法,您必须传入函数,如下所示tree_methodtrain

import xgboost as xgb
...
parameters = {'tree_method': 'exact'} #You can add other parameters as well
model = xgb.train(parameters, x_train, num_round) #num_round is the number of rounds for boosting
prediction = model.predict(x_test)
...

我希望这有帮助。