WIP add score_samples method in base search CV and add tests#16275
WIP add score_samples method in base search CV and add tests#16275maskani-moh wants to merge 3 commits intoscikit-learn:masterfrom
Conversation
|
Please check the linter errors |
maskani-moh
left a comment
There was a problem hiding this comment.
Help needed on the test here, as it fails because the message error is not caught. The test should check that it actually errors out.
| # the method `score_samples` | ||
| err_msg = "AttributeError: 'DecisionTreeClassifier' object has " \ | ||
| "no attribute 'score_samples'" | ||
| assert_raise_message(AttributeError, err_msg, clf.score_samples, X) |
There was a problem hiding this comment.
It seems that the error here is not caught and the test fails. How can I catch the error?
AttributeError: 'DecisionTreeClassifier' object has no attribute 'score_samples'"
There was a problem hiding this comment.
Try:
err_msg = ("'DecisionTreeClassifier' object has no attribute "
"'score_samples'")
with pytest.raises(AttributeError, match=err_msg):
clf.score_samples(X)
thomasjpfan
left a comment
There was a problem hiding this comment.
Thank you for the PR @maskani-moh !
| Parameters | ||
| ---------- | ||
| X : iterable | ||
| Data to predict on. Must fulfill input requirements of first step |
There was a problem hiding this comment.
What about:
Must fulfill input requirements of the underlying estimator
| # the method `score_samples` | ||
| err_msg = "AttributeError: 'DecisionTreeClassifier' object has " \ | ||
| "no attribute 'score_samples'" | ||
| assert_raise_message(AttributeError, err_msg, clf.score_samples, X) |
There was a problem hiding this comment.
Try:
err_msg = ("'DecisionTreeClassifier' object has no attribute "
"'score_samples'")
with pytest.raises(AttributeError, match=err_msg):
clf.score_samples(X)|
|
||
|
|
||
| @pytest.mark.filterwarnings("ignore:The parameter 'iid' is deprecated") # 0.24 | ||
| @pytest.mark.parametrize('search_cv', [RandomizedSearchCV, GridSearchCV]) |
There was a problem hiding this comment.
We can create the objects here:
@pytest.mark.parametrize('search_cv',
[RandomizedSearchCV(estimator=..., param_distributions=...)And we will not need the if statement in the test.
|
|
||
| @pytest.mark.filterwarnings("ignore:The parameter 'iid' is deprecated") # 0.24 | ||
| @pytest.mark.parametrize('search_cv', [RandomizedSearchCV, GridSearchCV]) | ||
| def test_search_cv_score_samples_method(search_cv): |
There was a problem hiding this comment.
We can create the objects here:
@pytest.mark.parametrize('search_cv',
[RandomizedSearchCV(estimator=..., param_distributions=...)And we will not need the if statement in the test.
|
Thanks @thomasjpfan for your feedback! |
|
are you still working on this? |
Reference Issues/PRs
Fixes #12542
What does this implement/fix? Explain your changes.
With the changes we'll be now able to call
score_sampleson the estimator with the best found parameters in *SearchCV instances.