Skip to content

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

Merged
qinhanmin2014 merged 11 commits into
scikit-learn:masterfrom
zjpoh:change_nmf_init
Jan 30, 2019
Merged

qinhanmin2014 merged 11 commits into
scikit-learn:masterfrom
zjpoh:change_nmf_init

Conversation

@zjpoh

@zjpoh zjpoh commented Jan 16, 2019

Copy link
Copy Markdown
Contributor

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.

Comment thread sklearn/decomposition/nmf.py Outdated

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

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.

0.23

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.

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

@jnothman jnothman left a comment

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.

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
Copy Markdown
Member

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

@jnothman jnothman left a comment

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.

Tests failing

@jnothman

Copy link
Copy Markdown
Member

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

@zjpoh

zjpoh commented Jan 22, 2019

Copy link
Copy Markdown
Contributor Author

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

@zjpoh

zjpoh commented Jan 23, 2019

Copy link
Copy Markdown
Contributor Author

@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
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
Copy Markdown
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
Copy Markdown
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.

@qinhanmin2014 qinhanmin2014 left a comment

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.

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.

Comment thread doc/whats_new/v0.21.rst Outdated
: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
Copy Markdown
Member

Choose a reason for hiding this comment

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

redundant space

Comment thread sklearn/decomposition/nmf.py Outdated
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
Copy Markdown
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

@qinhanmin2014 qinhanmin2014 left a comment

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.

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