-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add warnings for conflicts between fixed params and param grids #297
Add warnings for conflicts between fixed params and param grids #297
Conversation
…arnings in config.py so that user will be warned of conflicts and if grid_search is False and param_grids/fixed_parameters are specified (or at least one of them)
skll/config.py
Outdated
'cases.'.format(learner, | ||
', '.join(overlap_params))) | ||
else: | ||
if param_grid_list or fixed_parameter_list: |
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.
What's the problem with specifying fixed_parameter_list
even if we aren't doing grid search?
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.
Fixed it
…en_fixed_params_and_param_grids_185
…en_fixed_params_and_param_grids_185
Okay, @aoifecahill and I talked about this a bit and we think this is a little bit tricker:
Thoughts? |
Seems pretty clear to me. I'll update this shortly. |
To me it would make the most sense in this case for the fixed parameter to win out over the default parameter grid. We could just modify the grid for them automatically and likely get them what they wanted. |
Hmm, yeah I agree. That's a better way of doing it but we should still output a warning saying that we did that. |
Yeah, I agree about the warning. |
Couple observations:
|
…lues; make new unit test to test for conflicts when both are specified in the configuration file (more unit tests to come soon)
… parameter grids can be attained and add a new unit test in (more to come later)
…en_fixed_params_and_param_grids_185
…ing bad learner names themselves
Ok, I've made a bunch of changes and I think this is finished -- or, at least, I don't want to work on this further until somebody else takes a look because I had to change quite a few things and I want to know first if this is what you had in mind. As I mentioned earlier, in order to intelligently resolve conflicts, logging warnings sometimes, raising exceptions others, or doing some things silently, the approach had to be much more involved than it was initially. Partially this is due to the scope of the PR changing a little after further discussion. Anyway, tests pass locally, so I'm fairly certain that it works as is. |
doc/run_experiment.rst
Outdated
(and the defaults will be used). | ||
(and the defaults will be used). If there is a conflict between parameters | ||
specified in :ref:`param_grids` and :ref:`fixed_parameters`, :ref:`param_grids` | ||
values will take precedence. |
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.
Isn't this the opposite of what we finally agreed on (after @dan-blanchard's comment)?
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 haven't dealt with updating the documentation yet after making the most recent changes and I'd prefer to get the greenlight on what I have so far before making those changes.
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.
Ah, okay. I just wanted to make sure that the code has been updated to do the right thing and it's just the documentation that's out of sync.
…heck in config.py
So, it seems that some of my tests are failing, but not the ones that are really for the core of this PR. Specifically, they are the tests for the learner names in the config file. I thought that I could simply tests all the input names and then raise an exception if they weren't in the list of learner classes. But, I wasn't accounting for custom learners. What I'm wondering is: did you not have this type of check specifically to allow custom learners? I could change my exception to a warning that simply says that the user is using an unrecognized/custom learner. Or I could take it out. Also, the reason I had added that in there was because I needed to be able to refer to a learner's corresponding class (without using |
Yeah, I think we weren't checking the learners's identity because people could write custom learners. I think this PR requires a bit of careful reviewing since the scope has expanded. I would like all of us to think about this carefully and reach a consensus. So, this can probably go into either 1.2.1 or 1.3, whatever release we do next. |
The check for a valid learner type, which my changes fail on due to the fact that users can provide custom learners, could actually be resolved just simply by checking if the learner ends with ".py", couldn't it? I think the error that I have put in could be kept without much modification. I see now that it's a little more complicated. I thought that the learner name itself ended in .py for some reason, but that's only true for the |
…en_fixed_params_and_param_grids_185
…en_fixed_params_and_param_grids_185
…nd paramater grids
eed801c
to
6d82e56
Compare
The coverage decreased, but all that was added (now that some things have been removed) are basically logging statements. Tests could be added to check that the statements are logged, but I'm wondering if it's necessary or more trouble than it's worth in this case. |
wouldn't we want to check that the correct warnings are being logged for the various scenarios? |
It would be good, sure, but there are no checks for any of the other logging statements in similar situations. Also, it seems to me that it would be better if all of the warnings were actual warnings (that could be written to the log as well). That would be easier to test. |
Ah yes, true. But since PR #380 has been merged, shouldn't that now be possible? i.e. using proper logging and verifying the logging messages? |
Yeah, I see the case where it was used to verify the number of folds, etc. I think it's possible. I just wonder about 1) how worthwhile it is and 2) whether the warnings should be more like actual warnings. I can get around to adding some tests using the log statements for now. |
Yes, I agree that the warning should be more like actual warning following the logging changes that @desilinguist implemented recently. |
5 similar comments
I have now added some tests that search for the warning in the log file. What I mean about using actual warnings, though, was about using the I think this is ready to go again. |
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.
Just some minor rephrasing of the warning text which would require changing the tests as well. Thanks again for taking care of this!
skll/config.py
Outdated
@@ -582,6 +581,23 @@ def _parse_config_file(config_path, log_level=logging.INFO): | |||
# using the defaults? | |||
do_grid_search = config.getboolean("Tuning", "grid_search") | |||
|
|||
# Check if `param_grids` is specified, but `grid_search` is False | |||
if param_grid_list and not do_grid_search: | |||
logger.warning('"param_grids" was specified despite the fact that ' |
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'd rephrase this to state simply that Since "grid_search" is set to False, the specified "param_grids" will be ignored.
.
skll/config.py
Outdated
# `param_grid_list` (or values passed in by default) if | ||
# `do_grid_search` is True | ||
if do_grid_search and fixed_parameter_list: | ||
logger.warning('"grid_search" is set to True and "fixed_parameters"' |
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.
Minor rephrasing: Note that "grid_search" is set to True and "fixed_parameters" is also specified. If there is a conflict between the grid search parameter space and the fixed parameter values, the fixed parameter values will take precedence.
Added warnings for conflicts between fixed parameters and parameter grids and for when grid search is set to False and paramater grids are specified.