Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sotagg
Copy link
Contributor

@sotagg sotagg commented Oct 26, 2025

What does this implement/fix? Explain your changes.

The double-centered squared dissimilarity matrix is just $C\Delta C$, and the gram matrix $B$ is $-\frac{1}{2}$ times that result. Classical MDS performs eigendecomposition on this gram matrix.

However, the documentation states that eigendecomposition is performed on the double-centered matrix of squared dissimilarities, which is incorrect.

@github-actions
Copy link

github-actions bot commented Oct 26, 2025

βœ”οΈ Linting Passed

All linting checks passed. Your pull request is in excellent shape! β˜€οΈ

Generated for commit: 25a971e. Link to the linter CI: here

@dkobak
Copy link
Contributor

dkobak commented Oct 28, 2025

I don't mind this edit, but please write "Gram matrix" with capital "G", because Gram is a name.

the documentation states that eigendecomposition is performed on the double-centered matrix of squared dissimilarities, which is incorrect.

Well, your version may be more precise, but the current formulation is not incorrect. These matrices differ by a constant factor (-0.5), so they have the same eigenvectors.

@sotagg
Copy link
Contributor Author

sotagg commented Oct 29, 2025

I don't mind this edit, but please write "Gram matrix" with capital "G", because Gram is a name.

Thank you for pointing it out. This is fixed now.

Copy link
Member

@betatim betatim left a comment

Choose a reason for hiding this comment

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

I'm not an expert on MDS but from doing a bit of reading I think that the suggestion from this PR makes it more precise what is going on and maybe also more familiar to readers who are experts on the topic.

It would be good to have the opinion of someone who is an expert on this topic. Just to make sure we are not missing some edge case or second order level of detail. Many things in scikit-learn are the way they are for a reason, even if that reason isn't obvious at first (of course there are also many things that should be improved :D).

loss function with a different loss function called *strain*, which has an
exact solution in terms of eigendecomposition of the double-centered matrix
of squared dissimilarities. If the dissimilarity matrix consists of the pairwise
exact solution in terms of eigendecomposition of the Gram matrix.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather write here simply "exact solution in terms of eigendecomposition", and delete "of the Gram matrix". At this point in the text the Gram matrix has not yet been introduced, so it may be confusing. The point of the sentence is rather to say that the solution in terms of EIG exists. The below we can explain what the Gram matrix is etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds fair. I'll update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, this can be resolved.

@sotagg
Copy link
Contributor Author

sotagg commented Oct 29, 2025

I made the relationship between the Gram matrix and the loss function clearer.

@sotagg
Copy link
Contributor Author

sotagg commented Oct 29, 2025

On a side note, should Classical MDS also be in a dropdown like Metric and Non-metric MDS? If so, I'll fix this.

@dkobak
Copy link
Contributor

dkobak commented Oct 29, 2025

On a side note, should Classical MDS also be in a dropdown like Metric and Non-metric MDS? If so, I'll fix this.

I think the first paragraph and the image should be outside of a dropdown, but you can put the paragraph below the figure (beginning with "Formally") into a dropdown if you like.

@sotagg
Copy link
Contributor Author

sotagg commented Oct 30, 2025

I think the first paragraph and the image should be outside of a dropdown, but you can put the paragraph below the figure (beginning with "Formally") into a dropdown if you like.

Thanks for the suggestion. Since it seems like a stylistic choice, I'll leave it as is for now.

@lucyleeow lucyleeow added the Waiting for Second Reviewer First reviewer is done, need a second one! label Oct 31, 2025
@dkobak
Copy link
Contributor

dkobak commented Nov 1, 2025

This PR looks good to me now (as the author of the ClassicalMDS class).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants