Skip to content

[MRG] Feature: calculate normed stress (Stress-1) in sklearn.manifold.MDS#10168

Closed
Borchmann wants to merge 3 commits intoscikit-learn:mainfrom
Borchmann:stress1
Closed

[MRG] Feature: calculate normed stress (Stress-1) in sklearn.manifold.MDS#10168
Borchmann wants to merge 3 commits intoscikit-learn:mainfrom
Borchmann:stress1

Conversation

@Borchmann
Copy link
Copy Markdown

@Borchmann Borchmann commented Nov 19, 2017

Change introduces additional parameter to sklearn.manifold.MDS, namely normalize (default False), that can be used to return and use Stress-1 instead of raw Stress value. Already implemented stress_ attribute contains raw stress defined as:

zrzut ekranu 2017-11-19 o 02 00 40

The raw Stress value itself is not very informative, and its high value does not necessarily indicate bad fit. A better way of communicating reliability is to calculate a normed stress, eg. with Stress-1 implemented in current PR:

zrzut ekranu 2017-11-19 o 02 00 48

According to Kruskal (1964, p. 3): value 0 indicates "perfect" fit, 0.025 excellent, 0.05 good, 0.1 fair, and 0.2 poor.

For more information cf. Kruskal (1964, p. 8-9) and Borg (2005, p. 41-43).

@Borchmann Borchmann changed the title Feature: calculate normed stress (Stress-1) in sklearn.manifold.MDS [MRG] Feature: calculate normed stress (Stress-1) in sklearn.manifold.MDS Nov 19, 2017
Copy link
Copy Markdown
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 for the PR. Without much erudition around MDS, I'll review engineering...

You can't change a public interface without backwards compatibility. So you'll have to add a return_normed_stress attribute to smacof (or use a parameter to switch between normed and raw stress).

You also should test that the attribute on MDS is correctly set in the test file.

@Borchmann
Copy link
Copy Markdown
Author

@jnothman: Thanks for review. That's right, I adjusted PR to your suggestions.

Now, Stress-1 is used and returned instead of raw Stress when normalize parameter is set to True (False by default). Test for added feature was also proposed (it relies on property of normed stress that it is expected to be the same for input matrix multiplied by some factor "k").

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

I would add an entry in what's new as well

disparities and the distances for all constrained points).
The final value of the stress. By default, sum of squared distance
of the disparities and the distances for all constrained points.
If normalize is set to True, returns Stress-1 (according to
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.

You could add a Reference section and reference to this part.

disparities and the distances for all constrained points).
The final value of the stress. By default, sum of squared distance
of the disparities and the distances for all constrained points.
If normalize is set to True, returns Stress-1 (according to
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.

same remarks as above


# Normed stress should be the same for
# values multiplied by some factor "k"
assert_array_almost_equal(stress1, stress2, decimal=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.

Could you use allclose instead of almost_equal

normalize : boolean, optional, default: False
Whether use and return normed stress value (Stress-1) instead of raw
stress calculated by default.

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.

add a versionadded directive

@asanakoy
Copy link
Copy Markdown
Contributor

@glemaitre, I can fulfill the last request if @Borchmann is not active.

@mattmilten
Copy link
Copy Markdown

Is there still something blocking this PR?

@asanakoy
Copy link
Copy Markdown
Contributor

asanakoy commented Oct 4, 2018

@mattmilten I'm a bit busy with other projects now, go ahead if you would like to fix this.

@rotheconrad
Copy link
Copy Markdown
Contributor

Any news on this feature? The current stress value is basically useless. It would be really nice for users to have access to the normalized stress value from the main the scikit-learn package install without modifying anything.

rotheconrad added a commit to rotheconrad/scikit-learn that referenced this pull request Aug 4, 2020
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.
@rotheconrad rotheconrad mentioned this pull request Aug 4, 2020
@metalbobinou
Copy link
Copy Markdown

metalbobinou commented Oct 8, 2020

Any news on this feature? The current stress value is basically useless. It would be really nice for users to have access to the normalized stress value from the main the scikit-learn package install without modifying anything.

Same here... I'm trying to use MDS and check the Kruskal Stress for my current work... and I was thinking it was already implemented by seeing the 3 years old stackoverflow topic : stress-attribute-sklearn-manifold-mds-python

@cmarmo
Copy link
Copy Markdown
Contributor

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

None yet

Development

Successfully merging this pull request may close these issues.

9 participants