Solve the term synonym task for given embeddings and pairs of synonyms. This task similarly to analogy_task validates the quality of the embeddings. Here the terms in pairs are synonyms -- are related to the same object, so their embeddings should be close to one another. For every ordered pair of embeddings (term1, term2) the task is solved if term2 is in the n closest terms to term1.

synonym_task(term_vectors, n = 1, terms)

Arguments

term_vectors

A matrix of embeddings of the terms

n

A number of neighbors included in the context (default: 1)

terms

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

Value

A list of:

accuracy

An accuracy of the fulfilled questions

questions

A data frame of the all synonym questions and results

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)))
terms <- terms_pairs_test$synonym synonym_task(term_vectors, 1, terms)
#> Error in rownames(term_vectors): object 'term_vectors' not found
synonym_task(term_vectors, 5, terms)
#> Error in rownames(term_vectors): object 'term_vectors' not found