Title: | Wrappers for 'NGT' |
---|---|
Description: | Wrappers for 'NGT' (Neighborhood Graph and Tree for indexing high-dimensional data) which performs high-speed approximate nearest neighbor searches against a large volume of data in high dimensional vector data space. |
Authors: | Akiru Kato [aut, cre] |
Maintainer: | Akiru Kato <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.0.0.9001 |
Built: | 2024-09-02 04:53:56 UTC |
Source: | https://github.com/paithiov909/RNGT |
A GloVe model that trained on 11,446 Pokémon parties (for single battles in 2018), while considering each party as a sentence and each Pokémon as a word, and pruning vocabularies.
gen7singles2018
gen7singles2018
An object of class tbl_df
(inherits from tbl
, data.frame
) with 181 rows and 66 columns.
Graph and tree based index.
path
path of the index.
new()
Creates a new NgtIndex
object.
NgtIndex$new(path, sub_dir = rand_name("NgtIndex"))
path
path to the NGT index.
sub_dir
sub-directory of the index.
a new NgtIndex
object.
open()
Opens a NGT index.
NgtIndex$open(read_only = FALSE, tree_disabled = FALSE, log_disabled = FALSE)
read_only
whether the index is read only.
tree_disabled
whether the tree is disabled.
log_disabled
whether the log is disabled.
create()
Creates an empty index with the specified parameters.
NgtIndex$create( dimension, edge_size_for_creation = 10, edge_size_for_search = 40, distance_type = c("l2", "l1", "normalized_l2", "hamming", "jaccard", "sparse_jaccard", "angle", "normalized_angle", "cosine", "normalized_cosine", "normalized_l2"), object_type = c("float", "byte", "float16") )
dimension
dimension of the vectors.
edge_size_for_creation
number of edges for each node in the graph.
edge_size_for_search
number of edges to search.
distance_type
distance type.
object_type
object type.
sub_dir
sub directory to store the index in.
search()
Searches for the k approximate nearest neighbors of the specifiecd query object.
NgtIndex$search( query, k = 20L, epsilon = 0.1, edge_size = -1L, expected_accuracy = -1, with_distance = TRUE )
query
query object.
k
number of nearest neighbors.
epsilon
epsilon which defines the explored range for the graph
edge_size
number of edges for each node to explore the graph
expected_accuracy
expected accuracy.
with_distance
whether to return distance.
tibble.
save()
Saves the index.
NgtIndex$save(path)
path
path to save the index. defaults to the path of the index.
remove()
Removes objects from the index by their IDs.
NgtIndex$remove(ids)
ids
IDs of the objects to be removed.
integers; ids
is returned invisibly as is.
refine_anng()
Refines the index with the specified parameters.
NgtIndex$refine_anng( epsilon, accuracy, num_edges, num_edges_for_search, batch_size )
epsilon
epsilon which defines the explored range for the graph
accuracy
expected accuracy.
num_edges
number of edges for each node to explore the graph
num_edges_for_search
number of edges to search.
batch_size
batch size.
get_object()
Gets objects from the index by their IDs.
NgtIndex$get_object(ids)
ids
IDs of the objects to be retrieved.
tibble.
reset_defaults()
Resets the default parameters of the index.
NgtIndex$reset_defaults( num_of_search_objects, search_radius, epsilon, edge_size, expected_accuracy )
num_of_search_objects
number of search objects.
search_radius
search radius.
epsilon
epsilon.
edge_size
edge size.
expected_accuracy
expected accuracy.
get_info()
Gets information of the index.
NgtIndex$get_info()
named numeric vector
build_index()
Builds the search index.
NgtIndex$build_index(num_threads = 1L, target_size_of_graph = 0L)
num_threads
number of threads to be used for building a search index.
target_size_of_graph
target size of the graph.
batch_insert()
Inserts data into the index and build a search index.
NgtIndex$batch_insert(data, num_threads = 1L)
data
data to be inserted.
num_threads
number of threads to be used for building the index.
the IDs of the inserted objects are returned invisibly.
insert()
Inserts a vector to the index.
To search with the index,
you need to call build_index
after call this method.
NgtIndex$insert(vec)
vec
vector to be inserted.
the ID of the inserted object is returned invisibly.
export_index()
Exports an index to a file.
NgtIndex$export_index(path)
path
path to save the index.
import_index()
Imports an index from a file.
NgtIndex$import_index(path)
path
path to load the index.
close()
Closes the index.
NgtIndex$close()