[ENH] MDS: Show Kruskal stress#6309
Merged
lanzagar merged 1 commit intobiolab:masterfrom Feb 17, 2023
Merged
Conversation
ff64af7 to
fed44cb
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #6309 +/- ##
=======================================
Coverage 87.47% 87.48%
=======================================
Files 316 316
Lines 68085 68115 +30
=======================================
+ Hits 59556 59589 +33
+ Misses 8529 8526 -3 |
fed44cb to
cbfedc3
Compare
lanzagar
requested changes
Feb 2, 2023
|
|
||
| self.embedding = None # type: Optional[np.ndarray] | ||
| self.effective_matrix = None # type: Optional[DistMatrix] | ||
| self.stress = None |
Contributor
There was a problem hiding this comment.
As shown by failing tests, this conflicts with the static method with the same name.
This results in a crash when setting the size of points to "Stress".
Contributor
Author
There was a problem hiding this comment.
It's not that I don't warn students about this exact mistake.
cbfedc3 to
56eff89
Compare
56eff89 to
2e01854
Compare
lanzagar
reviewed
Feb 10, 2023
Comment on lines
+416
to
+421
| def _compute_stress(self): | ||
| if self.embedding is None or self.effective_matrix is None: | ||
| return None | ||
| actual = scipy.spatial.distance.pdist(self.embedding) | ||
| actual = scipy.spatial.distance.squareform(actual) | ||
| return np.sqrt(np.sum((actual - self.effective_matrix) ** 2) | ||
| / (np.sum(self.effective_matrix ** 2) or 1)) |
Contributor
There was a problem hiding this comment.
It would probably be better to call get_stress and normalize the returned result.
2e01854 to
0d145ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #6070.
Description of changes
To reviewer: please check that I indeed called
update_stressfrom all places where it's needed -- and that it's not called multiple times.I don't know where to show the stress. Optimization box was about the best place. I don't want to put it on the graph, because then we'd need to at least allow the user to move it and ... no.
Includes