meyer-lab / tensorpack

A collection of tensor methods from the Meyer lab.
MIT License
2 stars 2 forks source link

Question about performing PCA #67

Closed Farnazmdi closed 2 months ago

Farnazmdi commented 1 year ago

Hey @cyrillustan! I was going to use your package for decomposition, and I realized that there is no scaling here.. Does your code assume that the tensor being inputted here is already normalized?

https://github.com/meyer-lab/tensorpack/blob/0a3a8e5a90666abe86c162285e07fa59c848249b/tensorpack/decomposition.py#L46C40-L46C40

Thanks, Farnaz

cyrillustan commented 1 year ago

Hey Farnaz, are you talking about CP or PCA? For CP, it is normalized here https://github.com/meyer-lab/tensorpack/blob/0a3a8e5a90666abe86c162285e07fa59c848249b/tensorpack/cmtf.py#L117 For PCA, the scaling is included in the $\Sigma$ matrix (or diag(S) in the code) of SVD, so eventually the score matrix bears the weights.

Farnazmdi commented 1 year ago

Hey Cyrillus, Thanks for your response. I was asking about the PCA. I didn't see the normalization in the perform_PCA(). So does it mean that we don't have to normalize the input data for perform_PCA() andtensorly's svd_interface() takes care of the normalization?

cyrillustan commented 1 year ago

Yes, for PCA, SVD deals with the scaling, so you don't have to normalize the data.