Skip to content

[MRG + 1] MLP bug fixes and removing decision_function#5718

Closed
glennq wants to merge 1 commit intoscikit-learn:masterfrom
glennq:mlp_fix
Closed

[MRG + 1] MLP bug fixes and removing decision_function#5718
glennq wants to merge 1 commit intoscikit-learn:masterfrom
glennq:mlp_fix

Conversation

@glennq
Copy link
Copy Markdown
Contributor

@glennq glennq commented Nov 4, 2015

@amueller
Fix the wrong way of using random_state and mistakenly modifying parameter loss. Some minor fixes and more tests also included.
Remove decision_function to make the design, particularly with _forward_pass cleaner.

BTW, I have already implemented dropout for MLP in my fork. I'm going to make a pull request for that once this one is merged.

@amueller
Copy link
Copy Markdown
Member

amueller commented Nov 4, 2015

Thanks. I'm pretty busy with the release but I'll try to review soon.
Travis is failing a doctest because predict_proba changed. It shouldn't have changed for multi-class, only multi-label, right?

btw @kastnerkyle @ogrisel @eickenberg wdyt about removing decision_function ? It seems pretty odd to me.

@glennq
Copy link
Copy Markdown
Contributor Author

glennq commented Nov 4, 2015

I think doctest has failed because the way we use random_state changed. So coefficient initialization is slightly different.
I don't think it is related to changes in predict_proba. I'll try to rewind the change in predict_proba on my local machine and see if the same failure appears

@amueller
Copy link
Copy Markdown
Member

amueller commented Nov 4, 2015

Ah, that's possible. But aren't the weights the first thing that is called with the RNG? Then you need to change the expected output of the doctest (as we just discussed ;)

@glennq
Copy link
Copy Markdown
Contributor Author

glennq commented Nov 4, 2015

I checkout the commit just after changing use of random_state, and the failure still remains, so I am pretty sure now it's due to change in random state.

I think the problem is that previously check_random_state is called before initializing coefs of every layer...

@amueller
Copy link
Copy Markdown
Member

amueller commented Nov 4, 2015

ah, ok. makes sense that it changed.

@glennq glennq changed the title MLP bug fixes and removing decision_function [MRG] MLP bug fixes and removing decision_function Nov 12, 2015
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is this not needed anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't want to change the value of self.loss, and self.loss is actually only used once in _backprop at line 225 in the original code and 223 in the modified version, so I moved the logic of using 'binary_log_loss' instead of 'log_loss' for multilabel case to line 224-225

@amueller
Copy link
Copy Markdown
Member

Apart from my comment LGTM. Thanks and sorry for the slow review.

@amueller
Copy link
Copy Markdown
Member

Can you please squash your commits? thanks.

@amueller
Copy link
Copy Markdown
Member

Could you also add a regression test that checks that the new multi-label behavior is correct that would have failed on the previous version?

@glennq
Copy link
Copy Markdown
Contributor Author

glennq commented Nov 21, 2015

You mean the previous version that always uses softmax in predict_proba? Sure, I'll add the new test and then squash all commits.

@amueller
Copy link
Copy Markdown
Member

Sorry for the long silence, I'll try to review this soon.

@amueller amueller changed the title [MRG] MLP bug fixes and removing decision_function [MRG + 1] MLP bug fixes and removing decision_function Feb 9, 2016
@amueller
Copy link
Copy Markdown
Member

amueller commented Feb 9, 2016

lgtm. @MechCoder wanna review?

@glennq
Copy link
Copy Markdown
Contributor Author

glennq commented Apr 22, 2016

hi @amueller , just checking if someone's going to review this PR.

>>> clf.predict_proba([[2., 2.], [1., 2.]]) # doctest: +ELLIPSIS
array([[ 0., 1.],
[ 0., 1.]])
array([[ 1.96718015e-04, 9.99803282e-01],
Copy link
Copy Markdown
Member

@raghavrv raghavrv May 15, 2016

Choose a reason for hiding this comment

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

Could you use ... (ellipsis) instead? Refer this

@MechCoder
Copy link
Copy Markdown
Member

Should this be done for the release?

@MechCoder MechCoder added this to the 0.18 milestone Sep 10, 2016
@jnothman
Copy link
Copy Markdown
Member

Probably should, since it's changing API of new code, especially given that
it has a +1 already.

On 11 September 2016 at 08:16, Manoj Kumar notifications@github.com wrote:

Should this be done for the release?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#5718 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEz6620v5NLWA4OVgkYJwpKDTmUhK6xks5qoyxEgaJpZM4GcEnU
.

in which a sample can belong to more than one class. For each class, the raw
output passes through the logistic function. Values larger or equal to `0.5`
are rounded to `1`, otherwise to `0`. For a predicted output of a sample, the
indices where the value is `1` represents the assigned classes of that sample::
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not tested in the multilabel test.

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Sep 12, 2016

@glennq once my comments are addressed, can you please rebase on top of the current master? As we want to release 0.18rc quickly please let us know if you don't have the time to do that to day and one of us will take care of finishing this PR.

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Sep 12, 2016

Actually let me do it.

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Sep 12, 2016

Merged by #7393. Thanks @glennq for the fix.

@ogrisel ogrisel closed this Sep 12, 2016
@amueller
Copy link
Copy Markdown
Member

@glennq you had a branch for dropout, right?

@glennq
Copy link
Copy Markdown
Contributor Author

glennq commented Sep 12, 2016

@ogrisel Thank you for merging this fix!
@amueller Yes it's in https://github.com/glennq/scikit-learn/tree/mlp_dropout_new . I can do a rebase and PR this evening if you need that for the release.

@amueller
Copy link
Copy Markdown
Member

@glennq we don't need it for the release, but a PR would be nice so we can review. It's a great feature to have.

@glennq
Copy link
Copy Markdown
Contributor Author

glennq commented Sep 12, 2016

@amueller Sure. Now that this one is merged, I'll make the dropout PR asap.

@amueller
Copy link
Copy Markdown
Member

@glennq sweet, thanks :)

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.

6 participants