Scikit-learn's sklearn.ensemble.GradientBoostingClassifier
(as well as other ensemble methods) stores its weak classifiers as a class attribute, in sklearn.ensemble.GradientBoostingClassifier.estimators_
. I am trying the XGBoost package, but it seems there is no straightforward way to access the model's sub-estimators, if at all. Is there a roundabout way of accessing these estimators, or I have to modify the XGBoost codebase to store them in a class attribute variable (or if I should bite the bullet and defer to the scikit-learn implementation)?
Asked
Active
Viewed 361 times
2

desertnaut
- 57,590
- 26
- 140
- 166

adamcatto
- 143
- 6
-
On second thought, my idea also requires native support for NaN handling, so sklearn's GradientBoostingClassifier does not work for me. In the meantime, I am using `sklearn.ensemble.HistGradientBoostingClassifier._predictors` as a proxy, but ideally I'd be able to access XGBoost sub-estimators. – adamcatto Dec 04 '21 at 22:56
1 Answers
1
Depending on your preferred output type, you can use the get_booster()
method to get a list of strings of each booster (credit to this post).
Alternatively, you can use XGBoost's built-in plot_tree()
method (documentation) to visualise each tree.

Chin Man KWAN
- 11
- 1
- 4