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

textmodel_lsa does not weigth correctly the v singular vectors with the singular values? #64

Open
JFChartier opened this issue Aug 15, 2023 · 1 comment

Comments

@JFChartier
Copy link

JFChartier commented Aug 15, 2023

Hello,

I think there is an error in the way the LSA is computed in textmodel_lsa.R. After the svd decomposition, the v singular vectors are usually weighed with the k remaining singular values. However, at line 80 the matrix v is multiplied column-wise with d instead of row-wise. See :

result$matrix_low_rank <- t(dec$v * dec$d)

If I'm not wrong, the correct way to weight the v singular vectors should be v %*% diag(d) ?
This is how the weighing is calculated in the text2vec package. See:
https://github.com/dselivanov/text2vec/blob/e3b9865057ba8dae713badbf71ca5160b7a6efa6/R/model_LSA.R#L76

Thanks!

@JFChartier JFChartier changed the title textmodel_lsa does not weigth correctly the 'v singular vectors' with the singular values? textmodel_lsa does not weigth correctly the v singular vectors with the singular values? Aug 15, 2023
@JFChartier
Copy link
Author

The column-wise weighing is correct when margin=feature because dec$u is a k*n matrix (where n is the number of documents). However when margin=documents, dec$v is a m*k matrix (where m is the number of features/words) so a column-wise multiplication does not make sense.

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

No branches or pull requests

1 participant