How to obtain a dataframe of trees from a CatBoost model similar to XGBoost's model.get_booster().trees_to_dataframe()

97 Views Asked by At

I'm working with CatBoost and I need to extract information about the trees generated by a trained CatBoost model in the form of a dataframe, similar to how it can be done with XGBoost using model.get_booster().trees_to_dataframe(). This information is helpful for further analysis and visualization.

Is there an equivalent method or approach in CatBoost to achieve this? If so, could you please provide a code example or guidance on how to obtain a dataframe of the trees from a CatBoost model?

Possibly these values should be there in the DataFrame or any other object with required information Tree Node ID Feature Split Yes No Missing Gain Cover

from xgboost import XGBRegressor

model = XGBRegressor(n_estimators=20, n_jobs=10,
                        objective='reg:squarederror')


model.fit(X[0]['train'], Y['train'])
trees = model.get_booster().trees_to_dataframe()

enter image description here

I want to get a similar DF with all details in catboost:

from catboost import CatBoostRegressor

model = CatBoostRegressor( iterations=10,
                            thread_count=10)
                        

model.fit(X['train'], Y['train'], cat_features=range(n_num_features, n_features))
0

There are 0 best solutions below