-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
TST raise explicit error when tags are missing #30248
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
Conversation
|
|
||
|
|
||
| def _yield_api_checks(estimator): | ||
| if not isinstance(estimator, BaseEstimator): |
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.
Did we made the decision to only really support estimators that inherit from BaseEstimator? If so, is it documented somewhere so third-party estimator developers can know.
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.
Yes, documented:
scikit-learn/doc/developers/develop.rst
Lines 95 to 98 in 296aba8
| Out of all the methods that an estimator implements, ``fit`` is usually the one you | |
| want to implement yourself. Other methods such as ``set_params``, ``get_params``, etc. | |
| are implemented in :class:`~sklearn.base.BaseEstimator`, which you should inherit from. | |
| You might need to inherit from more mixins, which we will explain later. |
And the example:
scikit-learn/doc/developers/develop.rst
Lines 313 to 344 in 296aba8
| >>> import numpy as np | |
| >>> from sklearn.base import BaseEstimator, ClassifierMixin | |
| >>> from sklearn.utils.validation import validate_data, check_is_fitted | |
| >>> from sklearn.utils.multiclass import unique_labels | |
| >>> from sklearn.metrics import euclidean_distances | |
| >>> class TemplateClassifier(ClassifierMixin, BaseEstimator): | |
| ... | |
| ... def __init__(self, demo_param='demo'): | |
| ... self.demo_param = demo_param | |
| ... | |
| ... def fit(self, X, y): | |
| ... | |
| ... # Check that X and y have correct shape, set n_features_in_, etc. | |
| ... X, y = validate_data(self, X, y) | |
| ... # Store the classes seen during fit | |
| ... self.classes_ = unique_labels(y) | |
| ... | |
| ... self.X_ = X | |
| ... self.y_ = y | |
| ... # Return the classifier | |
| ... return self | |
| ... | |
| ... def predict(self, X): | |
| ... | |
| ... # Check if fit has been called | |
| ... check_is_fitted(self) | |
| ... | |
| ... # Input validation | |
| ... X = validate_data(self, X, reset=False) | |
| ... | |
| ... closest = np.argmin(euclidean_distances(X, self.X_), axis=1) | |
| ... return self.y_[closest] |
| yield sparse_format + "_64", X | ||
|
|
||
|
|
||
| @ignore_warnings(category=FutureWarning) |
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.
For other reviewers, this is just shifting the original test down.
Fixes #30237
This adds an explicit error when tags are missing which would result in failure of collecting tests. This gives an explicit error on why the collection fails.