Skip to content

Update _mds.py - #18094

Closed
rotheconrad wants to merge 1 commit into
scikit-learn:mainfrom
rotheconrad:master
Closed

rotheconrad wants to merge 1 commit into
scikit-learn:mainfrom
rotheconrad:master

Conversation

@rotheconrad

Copy link
Copy Markdown
Contributor

Implemented the normalized stress value from Borchmann's stalled PR: #10168
With these changes, passing normalize=True returns a meaningful stress value between 0-1. The current returned stress value is basically useless. normalize is set to False by default.

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Any other comments?

Implemented the normalized stress value from Borchmann's stalled PR: scikit-learn#10168
With these changes, passing normalize=True returns a meaningful stress value between 0-1. The current returned stress value is basically useless. normalize is set to False by default.
@joshuacwnewton

joshuacwnewton commented Aug 7, 2020 •

Copy link
Copy Markdown
Contributor

Please note: I'm not a core maintainer. I'm leaving my review to help move things along, but two core maintainers will need to approve this PR for it to be merged. Thanks for your patience!

Hi @rotheconrad! Thanks for your contribution. I see you've mentioned #10168, but I wanted to add that there are two other open PRs (#12285 and #13042) that would also address this issue. I would recommend checking with the author of #13042 to verify the status of that PR, as there was some in-progress discussion regarding implementation details that could be relevant here.

@glemaitre

Copy link
Copy Markdown
Member

I am not really familiar with this technique. I read quickly the original reference: https://link.springer.com/content/pdf/10.1007/BF02289565.pdf.

In the previous PR, @jnothman raised the question if it was necessary to perform the normalization at each step of the SMACOF algorithm (I think that's why @amueller tag "benchmark needed").

From what I can read in p. 8-9, the raw stress does not have scale invariance property. Therefore, I think that one would need to play with the eps parameter depending on the input dataset. If stress-1 has this property, and if I understand properly, the stopping criterion will have the same meaning with different data.

@glemaitre glemaitre 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.

Comment thread sklearn/manifold/_mds.py
Pass an int for reproducible results across multiple function calls.
See :term: `Glossary <random_state>`.

normalize : boolean, optional, default: False

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.

Suggested change
normalize : boolean, optional, default: False
normalize : bool, default=False

Comment thread sklearn/manifold/_mds.py
Comment on lines +122 to +123
stress = np.sqrt(stress /
((disparities.ravel() ** 2).sum() / 2))

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.

Suggested change
stress = np.sqrt(stress /
((disparities.ravel() ** 2).sum() / 2))
stress = np.sqrt(
stress / ((disparities.ravel() ** 2).sum() / 2)
)

Comment thread sklearn/manifold/_mds.py
return_n_iter : bool, default=False
Whether or not to return the number of iterations.

normalize : boolean, optional, default: False

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.

Suggested change
normalize : boolean, optional, default: False
normalize : bool, default=False

Comment thread sklearn/manifold/_mds.py
Pre-computed dissimilarities are passed directly to ``fit`` and
``fit_transform``.

normalize : boolean, optional, default: False

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.

Suggested change
normalize : boolean, optional, default: False
normalize : bool, default=False

Base automatically changed from master to main January 22, 2021 10:52
@cmarmo cmarmo added Superseded PR has been replace by a newer PR and removed Stalled help wanted labels Apr 22, 2022
@cmarmo

cmarmo commented May 2, 2022

Copy link
Copy Markdown
Contributor

Closing as superseded by #22562.

@cmarmo cmarmo closed this May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:manifold Superseded PR has been replace by a newer PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants