How to get access of individual trees of a xgboost model in python /R ?
Below I'm getting from Random Forest trees from sklearn .
estimator = RandomForestRegressor(oob_score=True, n_estimators=10,max_features='auto') estimator.fit(tarning_data,traning_target) tree1 = estimator.estimators_[0] leftChild = tree1.tree_.children_left
rightChild = tree1.tree_.children_right
Do you want to inspect the trees?
In Python, you can dump the trees as a list of strings:
>
Or dump them to a file (with nice formatting):
>