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
[MRG] add _pairwise property to BaseSearchCV #13925
Changes from 5 commits
52851c2
e492ca0
2546ef9
10abb32
a1e2413
907d5b2
5789be0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1787,3 +1787,30 @@ def get_n_splits(self, *args, **kw): | |
'inconsistent results. Expected \\d+ ' | ||
'splits, got \\d+'): | ||
ridge.fit(X[:train_size], y[:train_size]) | ||
|
||
|
||
def test_search_cv__pairwise_property(): | ||
""" | ||
Test implementation of BaseSearchCV has the _pairwise property | ||
which matches the _pairwise property of its estimator. | ||
""" | ||
|
||
class PairwiseCV(BaseSearchCV): | ||
def __init__(self, estimator, **kwargs): | ||
super().__init__(estimator, **kwargs) | ||
|
||
# simple estimator with _pairwise property | ||
est = BaseEstimator() | ||
|
||
attr_message = "BaseSearchCV _pairwise property must match estimator" | ||
|
||
# check estimator with and without _pairwise | ||
for _pairwise_setting in [True, False]: | ||
setattr(est, '_pairwise', _pairwise_setting) | ||
cv = PairwiseCV(est) | ||
|
||
# check if cv is pairwise | ||
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. this comment is redundant with the variable name |
||
cv_is_pairwise = getattr(cv, '_pairwise', False) | ||
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. why not just use 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 was following the convention of |
||
|
||
# verity the _pairwise property in cv matches est | ||
assert _pairwise_setting == cv_is_pairwise, attr_message |
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.
why not using GridSearchCV instead of creating a dummy class?