Skip to content

[MRG+1] Adding multi output checks to common tests #13392

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

Merged

Conversation

rok
Copy link
Contributor

@rok rok commented Mar 5, 2019

Reference Issues/PRs

Fixes #13187.

Changes

This implements new classifier and regressor checks to test for multi-output support in common tests.
Some random forest and tree classifier test are removed as they are duplicating this functionality.

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from 5328660 to b720e06 Compare March 7, 2019 14:39
@rok rok changed the title Adding multi output checks to common tests [MRG] Adding multi output checks to common tests Mar 7, 2019
Copy link
Member

@TomDLT TomDLT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about these tag changes (#13392 (comment)). ping @amueller

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from 33aa2ab to 8618a0e Compare March 17, 2019 00:50
Copy link
Member

@TomDLT TomDLT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update !
I like much more your Mixin fix now.

You will also need to add en entry in https://github.com/scikit-learn/scikit-learn/blob/master/doc/whats_new/v0.21.rst#changes-to-estimator-checks, writing the change, this PR number and your GitHub name.

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from 9450697 to 499fc5b Compare March 18, 2019 22:36
@jnothman
Copy link
Member

jnothman commented Mar 19, 2019 via email

@jnothman
Copy link
Member

jnothman commented Mar 19, 2019 via email

@rok
Copy link
Contributor Author

rok commented Mar 19, 2019

I wonder if requires_positive_data is implied by accepting pairwise data in all cases.

@jnothman - right, is there some other way to know?

Copy link
Member

@TomDLT TomDLT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

We just need to wait for a second review.

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from 85cf3c0 to c53179d Compare March 28, 2019 19:32
@rok
Copy link
Contributor Author

rok commented Apr 3, 2019

Ping! :)

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from 6a222f3 to 9a482b6 Compare April 11, 2019 16:42
@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch 5 times, most recently from c9ceb6e to 3f3671b Compare May 9, 2019 23:43
@rok
Copy link
Contributor Author

rok commented May 10, 2019

I've rebased and maybe we could get it merged in v0.22? :)

@TomDLT TomDLT added this to the 0.22 milestone May 10, 2019
@rth rth self-requested a review June 25, 2019 12:10
@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch 3 times, most recently from 14df99b to 86e6baf Compare July 20, 2019 21:46
@rok
Copy link
Contributor Author

rok commented Jul 20, 2019

Rebased and fixed new issues. Since things changed it might be good to do another review.

@@ -146,6 +146,12 @@ def __init__(self, n_neighbors=5, weights='uniform',
metric_params=metric_params, n_jobs=n_jobs, **kwargs)
self.weights = _check_weights(weights)

def _more_tags(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be handled by _pairwise?

@amueller
Copy link
Member

The reason why we need to add the intermediate classes into the hierarchy is because we don't add the mixins to the correct (that is left) side, and so we can't have nice things #14044?

Would it be feasible / sensible to actually change the order of mixins and allow overwriting tags? That would simplify a bunch of this, right?

@amueller
Copy link
Member

posted #14635 which will probably simplify this

@amueller
Copy link
Member

amueller commented Sep 4, 2019

ok this has a chance to be merged soon and would make this much easier: #14884

@jnothman
Copy link
Member

With #14884 merged, and a bunch of nitpicks above, are you going to bring this to conclusion, @rok? Thanks.

@rok
Copy link
Contributor Author

rok commented Sep 20, 2019

@jnothman - will try to finish this tonight. Sorry for the delay :)

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch 3 times, most recently from 0f23831 to 1969e70 Compare September 21, 2019 12:45
@rok
Copy link
Contributor Author

rok commented Sep 21, 2019

I'm not sure if I got the general approach right but I have:

  • moved mixins to the left
  • replaced intermediate classes by adding _more_tags to classes that inherit multioutput tag as True but should have it set to False. E.g. Lars is a multioutput class but LarsCV that inherits tags from Lars is not. We adjust LarsCV tags.

Please review :).

Thanks for pushing this @glemaitre @jnothman @amueller!

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from 1969e70 to fd6c04d Compare September 23, 2019 21:08
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a couple of missing assert in the tests and I would add meaningful error message.
It would ease debugging when rolling your own estimator and that check_estimator is failing.

estimator.fit(X, y)
y_pred = estimator.predict(X)

assert y_pred.dtype == np.dtype('float')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an error message

"Multi-output predictions by a regressor are expected to be floating-point precision. Got {} instead".format(y_pred.dtype)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also have a similar style as before

assert y_pred.dtype.kind == 'f'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to set this to 'float64'.

@glemaitre glemaitre self-requested a review September 24, 2019 08:43
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So a couple of changes required.

@rok
Copy link
Contributor Author

rok commented Sep 24, 2019

Thanks @glemaitre. I'll do this tonight.

rok and others added 3 commits September 24, 2019 18:15
[MRG] Adding multi output checks to common tests (scikit-learn#13187)

Removing redundant tests.
Adding tests to check_classifier_multioutput and check_regressor_multioutput.
Co-Authored-By: Guillaume Lemaitre <g.lemaitre58@gmail.com>
@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from c1457ad to 8cef195 Compare September 24, 2019 16:17
@rok
Copy link
Contributor Author

rok commented Sep 24, 2019

@glemaitre done, please review. :)

@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch 2 times, most recently from bb8f4eb to 78f3938 Compare September 24, 2019 16:55
@rok rok force-pushed the adding_multi-output_checks_to_common_tests branch from 78f3938 to 8eabe3b Compare September 24, 2019 17:03
@rok
Copy link
Contributor Author

rok commented Sep 30, 2019

@glemaitre ping :)

@glemaitre glemaitre merged commit 5e4b275 into scikit-learn:master Oct 1, 2019
@glemaitre
Copy link
Member

Thanks @rok

@rok
Copy link
Contributor Author

rok commented Oct 1, 2019

Thanks all! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing multi-output checks in common tests
6 participants