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

Fix TreeExplainer instanciation when a tree in LightGBM Classifier model has n_features_in_tree = 1 #310

Merged
merged 6 commits into from
Feb 5, 2025

Conversation

CharlesCousyn
Copy link
Contributor

Hello,

I am opening this PR to fix the bug mentioned here for the TreeExplainer.

Let me know id it does fix the problem correctly!

@mmschlk mmschlk self-assigned this Jan 31, 2025
@mmschlk
Copy link
Owner

mmschlk commented Jan 31, 2025

Hey @CharlesCousyn, thank you so much for taking care of this! This is very appreciated!

One quick thing. Would you be able to add a very small unit test as a minimal example that would error in the current version without your fix but succeeds with your fix? This way the fix is future proof?

I think it would be good if the TreeExplainer is used to explain a very small "model" with only one feature. For this you could use a Custom Tree (here is some info on the custom tree: https://shapiq.readthedocs.io/en/latest/notebooks/tree_notebooks/treeshapiq_custom_tree.html).

Best Max!

@mmschlk mmschlk self-requested a review January 31, 2025 18:35
Copy link
Owner

@mmschlk mmschlk left a comment

Choose a reason for hiding this comment

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

Thank you so much!

Could you add a very small unit test as mentioned in the comment?

@CharlesCousyn
Copy link
Contributor Author

@mmschlk Done!

@CharlesCousyn CharlesCousyn requested a review from mmschlk February 3, 2025 19:30
@mmschlk
Copy link
Owner

mmschlk commented Feb 5, 2025

@mmschlk Done!

Amazing! I will check it out and merge it! :) Thank you again! :)

Copy link
Owner

@mmschlk mmschlk left a comment

Choose a reason for hiding this comment

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

Tested, it on the current main and the bug is fixed. :)

@mmschlk
Copy link
Owner

mmschlk commented Feb 5, 2025

This PR fixes and closes #286

@mmschlk mmschlk merged commit 4b04a2f into mmschlk:main Feb 5, 2025
7 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.

Can't instanciate TreeExplainer when a tree in LightGBM Classifier model has n_features_in_tree = 1
2 participants