Skip to content
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

TST Improve error message in DummyClassifier #14908

Merged

Conversation

@martinagvilas
Copy link
Contributor

martinagvilas commented Sep 6, 2019

Fix #14903

Add to the error message the constant value passed and the real possible values in the data when the constant value is not in the training data.

Add to the error message the constant value and real possible values when the constant value is not in the training data.
@massich
massich approved these changes Sep 6, 2019
Copy link
Contributor

massich left a comment

Just some minor stuff

sklearn/dummy.py Outdated Show resolved Hide resolved
sklearn/tests/test_dummy.py Outdated Show resolved Hide resolved
@martinagvilas

This comment has been minimized.

Copy link
Contributor Author

martinagvilas commented Sep 9, 2019

I added your suggestions and the CI checks seem to be passing now. Let me know what you think.

Copy link
Contributor

glemaitre left a comment

This is almost good.


- |Fix| :class:`dummy.DummyClassifiers()` now handles checking the existence
of the provided constant in multiouput cases.
:pr:`14908` by `Martina G. Vilas`_.

This comment has been minimized.

Copy link
@glemaitre

glemaitre Sep 9, 2019

Contributor

You would need to add user username in one of the file. Using :user: will be easier.

Suggested change
:pr:`14908` by `Martina G. Vilas`_.
:pr:`14908` by :user:`Martina G. Vilas <martinagvilas>`.
([2, 1, 2, 2],
{'constant': 'my-constant'},
"constant=my-constant.*Possible values.*[2, 1, 2, 2]")])
def test_constant_strategy_exceptions(y, params, err_msg):
X = [[0], [0], [0], [0]] # ignored

This comment has been minimized.

Copy link
@glemaitre

glemaitre Sep 9, 2019

Contributor

You can removed the "# ignored" comment.

"Constant.*should have shape"),
([2, 1, 2, 2],
{'constant': 'my-constant'},
"constant=my-constant.*Possible values.*[2, 1, 2, 2]")])

This comment has been minimized.

Copy link
@glemaitre

glemaitre Sep 9, 2019

Contributor
Suggested change
"constant=my-constant.*Possible values.*[2, 1, 2, 2]")])
"constant=my-constant.*Possible values.*[2, 1, 2, 2]")],
ids=["no-constant", "too-many-constant", "not-enough-output", "single-output"]
)
([2, 1, 2, 2],
{'constant': [2, 0]},
"Constant.*should have shape"),
(np.transpose([[2, 1, 2, 2], [2, 1, 2, 2]]),

This comment has been minimized.

Copy link
@glemaitre

glemaitre Sep 9, 2019

Contributor

You are missing the following case

(np.transpose([[2, 1, 2, 2], [2, 1, 2, 2]]),
 {'constant': [2, 'unknown']},
 "constant=my-constant.*Possible values.*[1, 2]")

This would be the multi-output case

"Constant.*should have shape"),
([2, 1, 2, 2],
{'constant': 'my-constant'},
"constant=my-constant.*Possible values.*[2, 1, 2, 2]")])

This comment has been minimized.

Copy link
@glemaitre

glemaitre Sep 9, 2019

Contributor

This is weird to get [2, 1, 2, 2]. I would have expected [1, 2] in self.classes_[k].

martinagvilas and others added 2 commits Sep 9, 2019
@glemaitre glemaitre merged commit fcc2624 into scikit-learn:master Sep 9, 2019
7 of 12 checks passed
7 of 12 checks passed
scikit-learn.scikit-learn Build #20190909.73 failed
Details
scikit-learn.scikit-learn (Linux py35_conda_openblas) Linux py35_conda_openblas failed
Details
scikit-learn.scikit-learn (Linux py35_ubuntu_atlas) Linux py35_ubuntu_atlas failed
Details
scikit-learn.scikit-learn (Linux pylatest_pip_openblas_pandas) Linux pylatest_pip_openblas_pandas failed
Details
ci/circleci: lint Your tests are queued behind your running builds
Details
LGTM analysis: C/C++ No code changes detected
Details
LGTM analysis: JavaScript No code changes detected
Details
LGTM analysis: Python No new or fixed alerts
Details
scikit-learn.scikit-learn (Linux32 py35_ubuntu_atlas_32bit) Linux32 py35_ubuntu_atlas_32bit succeeded
Details
scikit-learn.scikit-learn (Windows py35_pip_openblas_32bit) Windows py35_pip_openblas_32bit succeeded
Details
scikit-learn.scikit-learn (Windows py37_conda_mkl) Windows py37_conda_mkl succeeded
Details
scikit-learn.scikit-learn (macOS pylatest_conda_mkl) macOS pylatest_conda_mkl succeeded
Details
@glemaitre

This comment has been minimized.

Copy link
Contributor

glemaitre commented Sep 9, 2019

Thanks @martinagvilas, looking forward to the next PR ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.