-
-
Notifications
You must be signed in to change notification settings - Fork 270
Warning if fitted sklearn model being used #989
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
Changes from 1 commit
d224845
409c6c0
01a7c36
d08ad83
c72baee
274506b
acb8d66
3c3b3d8
1e90133
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1652,6 +1652,22 @@ def _prediction_to_probabilities(y: np.ndarray, model_classes: List[Any]) -> pd. | |
|
|
||
| user_defined_measures = OrderedDict() # type: 'OrderedDict[str, float]' | ||
|
|
||
| try: | ||
| # check if model is fitted | ||
| # 'predict' internally calls sklearn.utils.validation.check_is_fitted for every | ||
| # model-specific attribute it excepts, thus offering a more robust check than | ||
| # a generic simplified call of check_is_fitted(model_copy) | ||
| from sklearn.exceptions import NotFittedError | ||
|
|
||
| model_copy.predict(X_train) | ||
| warnings.warn( | ||
| "The model is already fitted!" | ||
| " This might cause inconsistency in comparison of results." | ||
| ) | ||
| except NotFittedError: | ||
| # model is not fitted, as is required | ||
| pass | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought in the Python call we discussed that perhaps we would check this at the first call to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, will make it into a function and push. As for its placement, I reconsidered it given that irrespective of what is called,
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mfeurer do you think this is something we should want? or do we just leave it to the extension devs to implement a warning if they see it fit?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of having this function as callback that can be implemented by the extension deves. And yes, I expected this function to be called from the run_model_on_task function. |
||
|
|
||
| try: | ||
| # for measuring runtime. Only available since Python 3.3 | ||
| modelfit_start_cputime = time.process_time() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.