| LatentSemanticAnalysis {text2vec} | R Documentation | 
Latent Semantic Analysis model
Description
Creates LSA(Latent semantic analysis) model. See https://en.wikipedia.org/wiki/Latent_semantic_analysis for details.
Usage
LatentSemanticAnalysis
LSA
Format
R6Class object.
Usage
For usage details see Methods, Arguments and Examples sections.
lsa = LatentSemanticAnalysis$new(n_topics) lsa$fit_transform(x, ...) lsa$transform(x, ...) lsa$components
Methods
- $new(n_topics)
- create LSA model with - n_topicslatent topics
- $fit_transform(x, ...)
- fit model to an input sparse matrix (preferably in - dgCMatrixformat) and then transform- xto latent space
- $transform(x, ...)
- transform new data - xto latent space
Arguments
- lsa
- A - LSAobject.
- x
- An input document-term matrix. Preferably in - dgCMatrixformat
- n_topics
- integerdesired number of latent topics.
- ...
- Arguments to internal functions. Notably useful for - fit_transform()- these arguments will be passed to- rsparse::soft_svd
Examples
data("movie_review")
N = 100
tokens = word_tokenizer(tolower(movie_review$review[1:N]))
dtm = create_dtm(itoken(tokens), hash_vectorizer(2**10))
n_topics = 5
lsa_1 = LatentSemanticAnalysis$new(n_topics)
d1 = lsa_1$fit_transform(dtm)
# the same, but wrapped with S3 methods
d2 = fit_transform(dtm, lsa_1)
[Package text2vec version 0.6.4 Index]