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
throw warning and update error message #3576
base: master
Are you sure you want to change the base?
throw warning and update error message #3576
Conversation
@DanGolding: happy if you also take a look |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3576 +/- ##
=======================================
Coverage 61.46% 61.46%
=======================================
Files 90 90
Lines 12746 12747 +1
=======================================
+ Hits 7834 7835 +1
Misses 4912 4912 ☔ View full report in Codecov by Sentry. |
shap/explainers/_tree.py
Outdated
@@ -182,7 +182,7 @@ def __init__( | |||
self.data = data | |||
if self.data is None: | |||
feature_perturbation = "tree_path_dependent" | |||
#warnings.warn("Setting feature_perturbation = \"tree_path_dependent\" because no background data was given.") | |||
warnings.warn("Setting feature_perturbation = \"tree_path_dependent\" because no background data was given.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change may impact a large fraction of users, so I think we should carefully consider what level of notification is appropriate. Would logging.info
be more appropriate here?
In the logging HOWTO guide, they recommend:
- To report events that occur "during normal operation of a program", use logging
info()
- To issue a warning regarding a particular runtime event, if the issue is avoidable and the client application should be modified to eliminate the warning, use
warnings.warn
To me, this seems like normal operation rather than an "issue", as this behaviour is described in the docs of tree explainer:
feature_perturbation : "interventional" (default) or "tree_path_dependent" (default when data=None)
My guess is that Scott commented this warning as it was becoming a bit annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your suggestion is implemented. Sorry that this took so long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe logging.warn
is deprecated in favour of logging.warning
.
Also, we should use a module-level logger rather than the root logger: log = logging.getLogger(__name__)
.
From the python howto docs:
It is strongly advised that you do not log to the root logger in your library. Instead, use a logger with a unique and easily identifiable name, such as the name for your library’s top-level package or module. Logging to the root logger will make it difficult or impossible for the application developer to configure the logging verbosity or handlers of your library as they wish.
Co-authored-by: connortann <71127464+connortann@users.noreply.github.com>
…update-error-message
Thanks for the review. I implemented your suggestion to have a custom logger for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Ah - probably the same discussion applies here about logging.INFO vs logging.WARNING. I'll hold off merging, pending the dicussion in our other thread... |
Overview
Supports #3574
Description of the changes proposed in this pull request:
Checklist
Unit tests added (if fixing a bug or adding a new feature)