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

Example plot #24

Open
Cdk29 opened this issue Jul 18, 2023 · 1 comment
Open

Example plot #24

Cdk29 opened this issue Jul 18, 2023 · 1 comment

Comments

@Cdk29
Copy link

Cdk29 commented Jul 18, 2023

Hi.

I did not managed to reproduce the example graph in the readme :

https://github.com/bnosac/doc2vec/blob/master/tools/example-viz.png

the one that preceed :

library(doc2vec)
library(word2vec)
library(uwot)
library(dbscan)
data(be_parliament_2020, package = "doc2vec")
x      <- data.frame(doc_id = be_parliament_2020$doc_id,
                     text   = be_parliament_2020$text_nl,
                     stringsAsFactors = FALSE)
x$text <- txt_clean_word2vec(x$text)
x      <- subset(x, txt_count_words(text) < 1000)

d2v    <- paragraph2vec(x, type = "PV-DBOW", dim = 50, 
                        lr = 0.05, iter = 10,
                        window = 15, hs = TRUE, negative = 0,
                        sample = 0.00001, min_count = 5, 
                        threads = 1)
model  <- top2vec(d2v, 
                  control.dbscan = list(minPts = 50), 
                  control.umap = list(n_neighbors = 15L, n_components = 3), umap = tumap, 
                  trace = TRUE)
info   <- summary(model, top_n = 7)
info$topwords

I tried several function from textplot, without succes.

Thanks for any hints.

@jwijffels
Copy link
Collaborator

jwijffels commented Jul 21, 2023

Can't find that code back myself
If I can recall what I did, I took the top words of the topics and took the embeddings of these (mapped to 2 dimensions) and next plotted these showing only relationships between the terms which were part of the topic.
Probably mapping with umap to 2 dimensions will get you there already.

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

2 participants