Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisualisationNotYetSupportedError: get_min_samples_leaf() is not implemented yet for XGBoost. #303

Open
SPDA36 opened this issue Aug 6, 2023 · 4 comments

Comments

@SPDA36
Copy link

SPDA36 commented Aug 6, 2023

As requested by the VisualisationNotYetSupportedError

---------------------------------------------------------------------------
VisualisationNotYetSupportedError         Traceback (most recent call last)
Cell In[298], line 6
      3 features = X_train_rfe.columns
      5 for i,ax in enumerate(axs.flatten()):
----> 6     tree_viz.rtree_feature_space(features=[features[i]], ax=ax)

File ~\miniconda3\envs\site-packages\dtreeviz\trees.py:1047, in DTreeVizAPI.rtree_feature_space(self, fontsize, ticks_fontsize, show, split_linewidth, mean_linewidth, markersize, colors, fontname, n_colors_in_map, features, figsize, ax)
   1045     features = self.shadow_tree.feature_names[0:min(n_features,2)] # pick first one/two features if none given
   1046 if len(features) == 1:  # univar example
-> 1047     _rtreeviz_univar(self.shadow_tree, fontsize, ticks_fontsize, fontname, show, split_linewidth, mean_linewidth, markersize, colors,
   1048                      features[0], figsize, ax)
   1049 elif len(features) == 2:  # bivar example
   1050     _rtreeviz_bivar_heatmap(self.shadow_tree, fontsize, ticks_fontsize, fontname, show, n_colors_in_map, colors,
   1051                             markersize, features, figsize, ax)
File ~\miniconda3\envs\\Lib\site-packages\dtreeviz\trees.py:1766, in _rtreeviz_univar(shadow_tree, fontsize, ticks_fontsize, fontname, show, split_linewidth, mean_linewidth, markersize, colors, feature, figsize, ax)
   1763 _format_axes(ax, shadow_tree.feature_names[featidx], shadow_tree.target_name, colors, fontsize, fontname, ticks_fontsize=ticks_fontsize, grid=False)
   1765 if 'title' in show:
-> 1766     title = f"Regression Tree Depth {shadow_tree.get_max_depth()}, Samples per Leaf {shadow_tree.get_min_samples_leaf()},\nTraining $R^2$={shadow_tree.get_score()}"
   1767     ax.set_title(title, fontsize=fontsize, color=colors['title'])
File ~\miniconda3\envs\Lib\site-packages\dtreeviz\models\xgb_decision_tree.py:242, in ShadowXGBDTree.get_min_samples_leaf(self)
    241 def get_min_samples_leaf(self):
--> 242     raise VisualisationNotYetSupportedError("get_min_samples_leaf()", "XGBoost")
VisualisationNotYetSupportedError: get_min_samples_leaf() is not implemented yet for XGBoost. Please create an issue on https://github.com/parrt/dtreeviz/issues if you need this. Thanks!
@tlapusan
Copy link
Collaborator

tlapusan commented Aug 8, 2023

@SPDA36, I noted it and will try to implement in the next days, thanks !

@SPDA36
Copy link
Author

SPDA36 commented Aug 9, 2023

@SPDA36, I noted it and will try to implement in the next days, thanks !

Thank you!!

@tlapusan
Copy link
Collaborator

@SPDA36 looking into the source code and your stack trace, I do remember that the rtree_feature_space viz method is not supported yet by xgboost. Would it help if you try it with sklearn library ?

I will give it a try on weekend to see if I can adapt it to xgboost also, but there were some issues to extract that information (min_sample_leaf) from xgboost tree metadata.

@SPDA36
Copy link
Author

SPDA36 commented Aug 10, 2023

@tlapusan
I have used .rtree_feature_space() with sklearn decision trees and random forest with zero issues. No worries if it wont work with xgboost, but I figured I would try since .rtree_feature_space() is such a cool feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants