get_annoy_model: Build RcppAnnoy model

Description Usage Arguments Examples

Description

RcppAnnoy model is used to retrieve the most similar vectors to a pivot one. This function builds the RcppAnnoy model.

Usage

1
get_annoy_model(vectors, number_trees, verbose = FALSE)

Arguments

vectors

matrix where each row is an observation. rownames should contain textual versions of the vectors.

number_trees

integer counting the number of trees to grow in RcppAnnoy (for neighbor search). More gives better results but is slower to compute.

verbose

display progress of model building, plus some error message when a datapoint place is not found

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)
}

pommedeterresautee/projector documentation built on May 5, 2019, 1:38 p.m.