GH-16757: Fix top_n_features in shap_summary_plot in R#16790
Open
tomasfryda wants to merge 1 commit intorel-3.46.0from
Open
GH-16757: Fix top_n_features in shap_summary_plot in R#16790tomasfryda wants to merge 1 commit intorel-3.46.0from
tomasfryda wants to merge 1 commit intorel-3.46.0from
Conversation
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an off-by-one issue in the R h2o.shap_summary_plot feature-selection logic so top_n_features renders exactly the requested number of features, and adds regression tests in both R and Python.
Changes:
- Fix
top_n_featuresslicing inh2o.shap_summary_plot(R) and drop unused factor levels before selecting features. - Add an R unit test covering typical and corner-case
top_n_featuresvalues (including0erroring and-1meaning “all”). - Add a Python unit test intended to validate
top_n_featuresbehavior via plotted y-axis labels.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| h2o-r/tests/testdir_misc/explain/runit_shap_summary_plot_top_n_features.R | Adds R regression tests for top_n_features sizing and corner cases. |
| h2o-r/h2o-package/R/explain.R | Fixes off-by-one feature selection and adds top_n_features == 0 validation. |
| h2o-py/tests/testdir_misc/explain/pyunit_shap_summary_plot_top_n_features.py | Adds Python regression test that inspects rendered tick labels to count displayed features. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
h2o-py/tests/testdir_misc/explain/pyunit_shap_summary_plot_top_n_features.py
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



#16757