Repository navigation
Sort eigenvalues before truncating in linear_discriminant - #192
Open
chenyangsu wants to merge 1 commit into
Open
chenyangsu wants to merge 1 commit into
chenyangsu wants to merge 1 commit into
Conversation
Member
|
Hello, Sorting on Can you clarify your comment about failing tests? Are you stating that the 2 new tests will fail on |
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.
In
linear_discriminant, slicingvals[:rank]andvecs[:, :rank]directly afternp.linalg.eig(inv_cov_w.dot(cov_b))relies on the returned eigenvalue ordering. For two classes separated only in band 1 with eigenvalues[0.0, 21.875],linear_discriminantreturns[0.0]and drops the separating eigenvector, and a 3-class 6-band case similarly returns[3.597, 9.14e-17]in place of[3.597, 0.951].Could we sort by
vals.realdescending before slicing the toprankcomponents, matchingprincipal_componentsandmnf? Happy to switch to a symmetric reformulation witheighinstead if you prefer.Testing:
SPECTRAL_DATA=.venv/sample-data pytest -m "not graphics" spectral/tests-> 1856 passed, 3 skipped (2 new tests inspectral/tests/test_spymath.pyfail ondevelop).