Skip to content

[MRG] MNT Use Vt instead of V as returned by svd()#17100

Merged
rth merged 3 commits intoscikit-learn:masterfrom
NicolasHug:pca_Vt
May 5, 2020
Merged

[MRG] MNT Use Vt instead of V as returned by svd()#17100
rth merged 3 commits intoscikit-learn:masterfrom
NicolasHug:pca_Vt

Conversation

@NicolasHug
Copy link
Copy Markdown
Member

@NicolasHug NicolasHug commented May 1, 2020

Scipy's linalg.svd or linalg.svd return X = U, S, Vt.

The code uses V instead of Vt in various places. It can get confusing when people are checking out how we do PCA etc...

U *= sqrt(X.shape[0] - 1)
else:
# X_new = X * V = U * S * V^T * V = U * S
# X_new = X * V = U * S * Vt * V = U * S
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As a side note, this comment and the one above were actually incorrect with the previous notation

Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

u and v are the output of `linalg.svd` or
:func:`~sklearn.utils.extmath.randomized_svd`, with matching inner
dimensions so one can compute `np.dot(u * s, v)`.
The input v should really be called vt to be consistent with scipy's
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.

For those who specific v as keyword argument?

I am starting to see the argument for pep 570 in (python 3.8).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I want to change it too but it's public :/

Definitely a good candidate for pep 570!

@NicolasHug
Copy link
Copy Markdown
Member Author

easy one @rth?

Copy link
Copy Markdown
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @NicolasHug !

@rth rth merged commit 226e5c4 into scikit-learn:master May 5, 2020
gio8tisu pushed a commit to gio8tisu/scikit-learn that referenced this pull request May 15, 2020
viclafargue pushed a commit to viclafargue/scikit-learn that referenced this pull request Jun 26, 2020
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants