bstewart / stm

An R Package for the Structural Topic Model
Other
402 stars 98 forks source link

Error in tsneAnchor(Q, verbose = verbose, init.dims = settings$init$tSNE_init.dims, : #236

Open pl1996 opened 4 years ago

pl1996 commented 4 years ago

Hello,

I tried to apply the stm with K=0 to my data and get an error message.

I typed in the following code:

twitter_date <- stm::stm(documents = delete$documents, vocab = delete$vocab, K = 0, prevalence = ~ CW, max.em.its = 150, data = meta, init.type = "Spectral")

and I got the following error message:

Beginning Spectral Initialization Calculating the gram matrix... Finding anchor words... Initializing tSNE with PCA... Using tSNE to project to a low-dimensional space... Error in tsneAnchor(Q, verbose = verbose, init.dims = settings$init$tSNE_init.dims, : an unknown error has occured in Rtsne

Can anyone help me how I can solve this problem? I did the same with another dataset and it works but now it does not work anymore.

santoroma commented 4 years ago

Hello @pl1996, It is really an unknown error inside Rtsne::Rtsne (see line 299 in R/spectral.R). Sometimes you can skip the error just by changing the dimensions of PCA initial projection before tSNE. It would help if you change the control parameter tSNE_init.dims (see STM). In my experience tSNE_init.dims=80 worked . You should add the control parameter in stm like that model <- stm (......., control <- list(tSNE_init.dims=80))

Hope it can help you

baggo42069 commented 1 year ago

Hello @pl1996 and @santoroma ,

I am having the same problem with similar code. It actually temporarily resolved itself about a month ago, but is no longer working. Also, changing the dimensions of the PCA initial projection did not resolve the issue.

Is there any new information on this issue?

Btw, my code is below, but it's very similar to the one above and in the stm vignette

stm(documents = out$documents, vocab = out$vocab, K = 0, prevalence =~ Other Reasons, max.em.its = 20, data = out$meta, init.type = "Spectral")

keoghca commented 1 year ago

I realize that this issue is quite old, but thought I'd post in case it helps someone else who comes across it. I had this problem but when I swept the global environment (after saving the R file), it magically worked when I re-ran the same code!