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

fix eigenvalues order issue #33

Merged
merged 2 commits into from Apr 16, 2019
Merged

fix eigenvalues order issue #33

merged 2 commits into from Apr 16, 2019

Conversation

cameronmartino
Copy link
Collaborator

One line change with out of order eigenvalues. Bug fix for #32 .

@@ -180,7 +180,7 @@ def _fit(self):
niter=self.iteration, tol=self.tol)
solution = U.dot(s_).dot(V.T)
explained_variance_ratio_ = np.diag(s_) / np.diag(s_).sum()
self.eigenvalues = np.diag(s_)
self.eigenvalues = np.diag(s_)[::-1]
self.explained_variance_ratio = list(explained_variance_ratio_)[::-1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

that's the culprit -- reversed one line, but not the other 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mortonjt Yes, a sneaky little bug snuck right by me. Thanks for pointing out!

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is probably ok for now -- but the longterm solution is to sort all of the eigenvalues, then np.argsort all of the columns in the samples and features.

This will require a larger unittest with say 5 dimensions. Can push PR later.

@mortonjt mortonjt merged commit eb392a4 into master Apr 16, 2019
@mortonjt
Copy link
Collaborator

Thanks for the quick fix @cameronmartino !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants