[go: nahoru, domu]

Skip to content
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

Update _mds.py #18094

Closed
wants to merge 1 commit into from
Closed

Update _mds.py #18094

wants to merge 1 commit into from

Conversation

rotheconrad
Copy link
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
Copy link
Contributor
joshuacwnewton commented Aug 7, 2020

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

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.

@@ -54,6 +55,10 @@ def _smacof_single(dissimilarities, metric=True, n_components=2, init=None,
Pass an int for reproducible results across multiple function calls.
See :term: `Glossary <random_state>`.

normalize : boolean, optional, default: False
Copy link
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 on lines +122 to +123
stress = np.sqrt(stress /
((disparities.ravel() ** 2).sum() / 2))
Copy link
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)
)

@@ -204,6 +217,10 @@ def smacof(dissimilarities, *, metric=True, n_components=2, init=None,
return_n_iter : bool, default=False
Whether or not to return the number of iterations.

normalize : boolean, optional, default: False
Copy link
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

@@ -326,6 +347,10 @@ class MDS(BaseEstimator):
Pre-computed dissimilarities are passed directly to ``fit`` and
``fit_transform``.

normalize : boolean, optional, default: False
Copy link
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

@glemaitre glemaitre added this to REVIEWED AND WAITING FOR CHANGES in Guillaume's pet Aug 20, 2020
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
Copy link
Member
cmarmo commented May 2, 2022

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
No open projects
Guillaume's pet
REVIEWED AND WAITING FOR CHANGES
Development

Successfully merging this pull request may close these issues.

None yet

4 participants