Description Usage Arguments Details Examples
Use RcppAnnoy to rapidly retrieve a list of vector neighbors.
1 2 | retrieve_neighbors(text, projection_type, annoy_model, n,
search_k = max(10000, 10 * n), center_pivot = TRUE, ...)
|
text |
character containing the text related to the pivot vector |
projection_type |
character defining the algorithm to use to compute the coordinates. ( |
annoy_model |
RcppAnnoy model |
n |
number of neighbors to retrieve |
search_k |
number of nodes to search in (RcppAnnoy parameter). Higher = ++precision & –speed |
center_pivot |
put pivot text in the middle of the graph |
... |
parameters passed to projection algorithm ( |
Transform original vectors in 2D coordinates applying either:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | if (interactive()){
# This example should be run with a higher quality model
# than the one embedded in fastrtext
library(projector)
library(fastrtext)
model_test_path <- system.file("extdata",
"model_unsupervised_test.bin",
package = "fastrtext")
model <- load_model(model_test_path)
word_embeddings <- get_word_vectors(model,
words = head(get_dictionary(model), 2e5))
annoy_model <- get_annoy_model(word_embeddings, 5)
selected_word <- "out"
df <- retrieve_neighbors(text = selected_word,
projection_type = "tsne",
annoy_model = annoy_model,
n = 1000)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.