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

[R] Throw explicit error when using categorical features in functions which don't support them #11077

Merged
merged 5 commits into from
Dec 15, 2024

Conversation

david-cortes
Copy link
Contributor

ref #9810
ref #9925

This PR adds an explicit error message when trying to call xgb.model.dt.tree and functions that depend on it (currently xgb.plot.multi.trees) on a model that has categorical features, as it fails to extract the splits from those.

It doesn't actually fix the issue - i.e. this PR doesn't fix the functions to make them work with categorical data - but instead just makes the error message understandable.

Should ideally be reverted once there is a C-level function to produce tables from trees with proper support for categorical splits.

Copy link
Member

@trivialfis trivialfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge once the CI is green.

@david-cortes
Copy link
Contributor Author

On second thought, I'm thinking it better to remove the text argument for trees-to-table:

  • Once a C-level function to get the table is added, it'd work from a booster object only instead of text dumps, so better to have the breaking change now before a CRAN release.
  • Having this text argument doesn't allow throwing an informative error when the model has categorical features.

@trivialfis
Copy link
Member

Once a C-level function to get the table is added

It might take a while, though. I'm working on storing the factor in the booster, as there are complaints about this being a foot gun.

@trivialfis
Copy link
Member

Could you please help resolve the conflicts?

@david-cortes
Copy link
Contributor Author

Could you please help resolve the conflicts?

Solved.

@trivialfis trivialfis merged commit dea5753 into dmlc:master Dec 15, 2024
58 checks passed
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

Successfully merging this pull request may close these issues.

2 participants