[MRG] Use base.is_classifier instead of isinstance#9482
[MRG] Use base.is_classifier instead of isinstance#9482lesteve merged 1 commit intoscikit-learn:masterfrom
Conversation
|
It's not essential to do this to check self, but I think this is good. LGTM |
|
Sorry is there a reason you marked it WIP? What is incomplete? |
|
I plan to add |
sklearn/tree/tree.py
Outdated
| from ..base import BaseEstimator | ||
| from ..base import ClassifierMixin | ||
| from ..base import RegressorMixin | ||
| from ..base \ |
There was a problem hiding this comment.
Please refrain from making changes unless there is a very strong reason behind it. This adds noise to the diff and this unnecessary messiness is quite annoying as a reviewer.
If your editor reorganises imports automatically, find a way to disable it.
Apart from this LGTM.
|
I don't think we should add other |
|
LGTM, too. But I particularly dislike the |
|
There was a missing I'll merge this one when the CIs are green. |
|
OK Travis is green, let's merge this one! Thanks @minghui-liu! |
|
Thank you, @lesteve |
Release 0.19.0 * tag '0.19.0': (99 commits) DOC one more version issue in doc skip docstring tests because not useful to users and has some issues deprecation of n_components happened in 0.19 not 0.18 (scikit-learn#9527) sync whatsnew with master so I'm less confused DOC more navigation links DOC a note on data leakage and pipeline (scikit-learn#9510) DOC set release date to Friday DOC Update news and menu for 0.19 release DOC list of contributors to 0.19 DOC Change release date to Thursday DOC Remove some whitespace from what's new Update what's new for recent changes Use base.is_classifier instead instead of isinstance (scikit-learn#9482) Fix safe_indexing with read-only indices (scikit-learn#9507) [MRG+1] add scorer based on explained_variance_score (scikit-learn#9259) fix wrong assert in test_validation (scikit-learn#9480) [MRG+1] FIX Add missing mixins to ClassifierChain (scikit-learn#9473) Bring last code block in line with the image. (scikit-learn#9488) FIX Pass sample_weight as kwargs in VotingClassifier (scikit-learn#9493) FIX Incorrent implementation of noise_variance_ in PCA._fit_truncated (scikit-learn#9108) ...
* releases: (99 commits) DOC one more version issue in doc skip docstring tests because not useful to users and has some issues deprecation of n_components happened in 0.19 not 0.18 (scikit-learn#9527) sync whatsnew with master so I'm less confused DOC more navigation links DOC a note on data leakage and pipeline (scikit-learn#9510) DOC set release date to Friday DOC Update news and menu for 0.19 release DOC list of contributors to 0.19 DOC Change release date to Thursday DOC Remove some whitespace from what's new Update what's new for recent changes Use base.is_classifier instead instead of isinstance (scikit-learn#9482) Fix safe_indexing with read-only indices (scikit-learn#9507) [MRG+1] add scorer based on explained_variance_score (scikit-learn#9259) fix wrong assert in test_validation (scikit-learn#9480) [MRG+1] FIX Add missing mixins to ClassifierChain (scikit-learn#9473) Bring last code block in line with the image. (scikit-learn#9488) FIX Pass sample_weight as kwargs in VotingClassifier (scikit-learn#9493) FIX Incorrent implementation of noise_variance_ in PCA._fit_truncated (scikit-learn#9108) ...
* dfsg: (99 commits) DOC one more version issue in doc skip docstring tests because not useful to users and has some issues deprecation of n_components happened in 0.19 not 0.18 (scikit-learn#9527) sync whatsnew with master so I'm less confused DOC more navigation links DOC a note on data leakage and pipeline (scikit-learn#9510) DOC set release date to Friday DOC Update news and menu for 0.19 release DOC list of contributors to 0.19 DOC Change release date to Thursday DOC Remove some whitespace from what's new Update what's new for recent changes Use base.is_classifier instead instead of isinstance (scikit-learn#9482) Fix safe_indexing with read-only indices (scikit-learn#9507) [MRG+1] add scorer based on explained_variance_score (scikit-learn#9259) fix wrong assert in test_validation (scikit-learn#9480) [MRG+1] FIX Add missing mixins to ClassifierChain (scikit-learn#9473) Bring last code block in line with the image. (scikit-learn#9488) FIX Pass sample_weight as kwargs in VotingClassifier (scikit-learn#9493) FIX Incorrent implementation of noise_variance_ in PCA._fit_truncated (scikit-learn#9108) ...
Reference Issue
Fixes #9475
What does this implement/fix? Explain your changes.
change
isinstance(estimator, ClassifierMixin)to usebase.is_classifier()andisinstance(estimator, RegressorMixin)to usebase.is_regressor()Any other comments?
There are also occurrences of
isinstance(estimator, TransformerMixin)andisinstance(estimator, ClusterMixin). I would like to addbase.is_transformer()andbase.is_cluster()methods and use them instead.