Visualize analogies for given terms. A visualization of embeddings is two main components from PCA plotted by ggplot on the 2D plane. Additionally, the terms from each given pair are connected to one another. If the embeddings are of good quality, the connection lines should be almost parallel to each other. If find_analogies = TRUE only the pairs with at least one solved analogy task are plotted.

visualize_analogies(term_vectors, terms, find_analogies = FALSE,
  n = 5L, save = FALSE, path_to_save)

Arguments

term_vectors

A matrix of embeddings of terms

terms

A list of two character vectors: the first and the second elements of analogy pairs

find_analogies

A logical indicating if the term analogy task should be performed before the plotting (default: FALSE)

n

An optional number of neighbors included in analogies (default: 5), needed only if find_analogies = TRUE

save

A logical indicating if the plot should be saved to the file

path_to_save

An optional string of the path to the target PDF file

Value

A generated plot of embeddings.

See also

Examples

term_vectors <- embed_terms(examinations, embedding_size = 5L, term_count_min = 1L)
#> Error in .subset2(public_bind_env, "initialize")(...): unused arguments (word_vectors_size = 5, vocabulary = list(c("fever", "man", "mother", "cough", "heart", "patient", "thyroid", "eye", "rhinitis", "woman", "father"), c(2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7), c(2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7)))
visualize_analogies(term_vectors, terms_pairs_test$person)
#> Error in rownames(term_vectors): object 'term_vectors' not found
visualize_analogies(term_vectors, terms_pairs_test$person, find_analogies = TRUE, n = 10)
#> Error in rownames(term_vectors): object 'term_vectors' not found