Skip to content

[MRG] NMF and non_negative_factorization have inconsistent default init #12989

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
merged 11 commits into from
Jan 30, 2019

Conversation

zjpoh
Copy link
Contributor

@zjpoh zjpoh commented Jan 16, 2019

Reference Issues/PRs

Fixes #12988. See also #11667.

What does this implement/fix? Explain your changes.

Changed the default in non_negative_factorization with a deprecation process.

@@ -986,6 +986,11 @@ def non_negative_factorization(X, W=None, H=None, n_components=None,
factorization with the beta-divergence. Neural Computation, 23(9).
"""

if init == "warn":
warnings.warn("The default value of init will change from "
"random to None in 0.22.", FutureWarning)
Copy link
Member

Choose a reason for hiding this comment

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

0.23

Copy link
Member

Choose a reason for hiding this comment

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

The behaviour won't change if n_components >= n_features so we could add that condition

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Thanks!

Please add an |API| entry to the change log at doc/whats_new/v0.21.rst. Like the other entries there, please reference this pull request with :issue: and credit yourself (and other contributors if applicable) with :user:

@jnothman
Copy link
Member

Sorry I shouldn't have approved: tests are failing. Maybe I've not reviewed correctly

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Tests failing

@jnothman
Copy link
Member

Travis still unhappy. Please remember to rename to MRG when you think this is safe to merge

@zjpoh
Copy link
Contributor Author

zjpoh commented Jan 22, 2019

Sure. I'm still figuring out how to make Travis happy. Will change the title after figuring it out.

@zjpoh
Copy link
Contributor Author

zjpoh commented Jan 23, 2019

@jnothman Travis is happy now.

@zjpoh zjpoh changed the title [WIP] NMF and non_negative_factorization have inconsistent default init [MRG] NMF and non_negative_factorization have inconsistent default init Jan 23, 2019
@@ -380,8 +382,8 @@ def test_nmf_negative_beta_loss():

def _assert_nmf_no_nan(X, beta_loss):
W, H, _ = non_negative_factorization(
X, n_components=n_components, solver='mu', beta_loss=beta_loss,
random_state=0, max_iter=1000)
X, init='random', n_components=n_components, solver='mu',
Copy link
Member

Choose a reason for hiding this comment

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

we should probably make sure that init is explicitly set elsewhere in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Added explicit init to all tests other than the consistency check test between NMF and non_negative_factorization.

Copy link
Member

@qinhanmin2014 qinhanmin2014 left a comment

Choose a reason for hiding this comment

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

Please add the reason of the deprecation in what's new and the deprecation message (e.g., to keep consistent with decomposition.NMF).
please explain init=None in the docstring of non_negative_factorization.
please add init=None to possible options and explain it in the docstring of NMF.

:func:`decomposition.non_negative_factorization` will change from
:code:`random` to :code:`None` to match :class:`decomposition.NMF`
in version 0.23. A FutureWarning is raised when the default value
is used. :issue:`12988` by :user:`Zijie (ZJ) Poh <zjpoh>`.
Copy link
Member

Choose a reason for hiding this comment

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

redundant space

if init == "warn":
if n_components < n_features:
warnings.warn("The default value of init will change from "
"random to None in 0.23.", FutureWarning)
Copy link
Member

Choose a reason for hiding this comment

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

please also mention the reason in the deprecation message

Copy link
Member

@qinhanmin2014 qinhanmin2014 left a comment

Choose a reason for hiding this comment

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

thanks @zjpoh

@qinhanmin2014 qinhanmin2014 merged commit bb3f93c into scikit-learn:master Jan 30, 2019
@zjpoh zjpoh deleted the change_nmf_init branch February 1, 2019 17:06
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NMF and non_negative_factorization have inconsistent default init
3 participants