View Source Evision.ANNIndex (Evision v1.0.0-rc.0)
Summary
Functions
Add feature vectors to index.
Build the index.
Build the index.
Creates an instance of annoy index class with given parameters
Creates an instance of annoy index class with given parameters
Return the number of feature vectors in the index.
Return the number of trees in the index.
Performs a K-nearest neighbor search for given query vector(s) using the index.
Performs a K-nearest neighbor search for given query vector(s) using the index.
Loads (mmaps) an index from disk.
Loads (mmaps) an index from disk.
Save the index to disk and loads it. After saving, no more vectors can be added.
Save the index to disk and loads it. After saving, no more vectors can be added.
Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)
Initialize the random number generator with the given seed. Only necessary to pass this before adding the items. Will have no effect after calling build() or load().
Types
@type t() :: %Evision.ANNIndex{ref: reference()}
Type that represents an ANNIndex struct.
ref.
reference()The underlying erlang resource variable.
Functions
@spec addItems(t(), Evision.Mat.maybe_mat_in()) :: t() | {:error, String.t()}
Add feature vectors to index.
Positional Arguments
self:
Evision.ANNIndex.t()features:
Evision.Mat.Matrix containing the feature vectors to index. The size of the matrix is num_features x feature_dimension.
Python prototype (for reference only):
addItems(features) -> None
@spec build(Keyword.t()) :: any() | {:error, String.t()}
@spec build(t()) :: t() | {:error, String.t()}
Build the index.
Positional Arguments
- self:
Evision.ANNIndex.t()
Keyword Arguments
trees:
integer().Number of trees in the index. If not provided, the number is determined automatically in a way that at most 2x as much memory as the features vectors take is used.
Python prototype (for reference only):
build([, trees]) -> None
Build the index.
Positional Arguments
- self:
Evision.ANNIndex.t()
Keyword Arguments
trees:
integer().Number of trees in the index. If not provided, the number is determined automatically in a way that at most 2x as much memory as the features vectors take is used.
Python prototype (for reference only):
build([, trees]) -> None
@spec create(Keyword.t()) :: any() | {:error, String.t()}
@spec create(integer()) :: t() | {:error, String.t()}
Creates an instance of annoy index class with given parameters
Positional Arguments
dim:
integer().The dimension of the feature vector.
Keyword Arguments
distType:
ANNIndex_Distance.Metric to calculate the distance between two feature vectors, can be DIST_EUCLIDEAN, DIST_MANHATTAN, DIST_ANGULAR, DIST_HAMMING, or DIST_DOTPRODUCT.
Return
- retval:
Evision.ANNIndex.t()
Python prototype (for reference only):
create(dim[, distType]) -> retval
Creates an instance of annoy index class with given parameters
Positional Arguments
dim:
integer().The dimension of the feature vector.
Keyword Arguments
distType:
ANNIndex_Distance.Metric to calculate the distance between two feature vectors, can be DIST_EUCLIDEAN, DIST_MANHATTAN, DIST_ANGULAR, DIST_HAMMING, or DIST_DOTPRODUCT.
Return
- retval:
Evision.ANNIndex.t()
Python prototype (for reference only):
create(dim[, distType]) -> retval
@spec getItemNumber(Keyword.t()) :: any() | {:error, String.t()}
@spec getItemNumber(t()) :: integer() | {:error, String.t()}
Return the number of feature vectors in the index.
Positional Arguments
- self:
Evision.ANNIndex.t()
Return
- retval:
integer()
Python prototype (for reference only):
getItemNumber() -> retval
@spec getTreeNumber(Keyword.t()) :: any() | {:error, String.t()}
@spec getTreeNumber(t()) :: integer() | {:error, String.t()}
Return the number of trees in the index.
Positional Arguments
- self:
Evision.ANNIndex.t()
Return
- retval:
integer()
Python prototype (for reference only):
getTreeNumber() -> retval
@spec knnSearch(t(), Evision.Mat.maybe_mat_in(), integer()) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}
Performs a K-nearest neighbor search for given query vector(s) using the index.
Positional Arguments
self:
Evision.ANNIndex.t()query:
Evision.Mat.The query vector(s).
knn:
integer().Number of nearest neighbors to search for.
Keyword Arguments
search_k:
integer().The maximum number of nodes to inspect, which defaults to trees x knn if not provided.
Return
indices:
Evision.Mat.t().Matrix that will contain the indices of the K-nearest neighbors found, optional.
dists:
Evision.Mat.t().Matrix that will contain the distances to the K-nearest neighbors found, optional.
Python prototype (for reference only):
knnSearch(query, knn[, indices[, dists[, search_k]]]) -> indices, dists
@spec knnSearch( t(), Evision.Mat.maybe_mat_in(), integer(), [{:search_k, term()}] | nil ) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}
Performs a K-nearest neighbor search for given query vector(s) using the index.
Positional Arguments
self:
Evision.ANNIndex.t()query:
Evision.Mat.The query vector(s).
knn:
integer().Number of nearest neighbors to search for.
Keyword Arguments
search_k:
integer().The maximum number of nodes to inspect, which defaults to trees x knn if not provided.
Return
indices:
Evision.Mat.t().Matrix that will contain the indices of the K-nearest neighbors found, optional.
dists:
Evision.Mat.t().Matrix that will contain the distances to the K-nearest neighbors found, optional.
Python prototype (for reference only):
knnSearch(query, knn[, indices[, dists[, search_k]]]) -> indices, dists
Loads (mmaps) an index from disk.
Positional Arguments
self:
Evision.ANNIndex.t()filename:
String.Filename of the index to be loaded.
Keyword Arguments
prefault:
bool.If prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.
Python prototype (for reference only):
load(filename[, prefault]) -> None
Loads (mmaps) an index from disk.
Positional Arguments
self:
Evision.ANNIndex.t()filename:
String.Filename of the index to be loaded.
Keyword Arguments
prefault:
bool.If prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.
Python prototype (for reference only):
load(filename[, prefault]) -> None
Save the index to disk and loads it. After saving, no more vectors can be added.
Positional Arguments
self:
Evision.ANNIndex.t()filename:
String.Filename of the index to be saved.
Keyword Arguments
prefault:
bool.If prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.
Python prototype (for reference only):
save(filename[, prefault]) -> None
Save the index to disk and loads it. After saving, no more vectors can be added.
Positional Arguments
self:
Evision.ANNIndex.t()filename:
String.Filename of the index to be saved.
Keyword Arguments
prefault:
bool.If prefault is set to true, it will pre-read the entire file into memory (using mmap with MAP_POPULATE). Default is false.
Python prototype (for reference only):
save(filename[, prefault]) -> None
Prepare to build the index in the specified file instead of RAM (execute before adding items, no need to save after build)
Positional Arguments
self:
Evision.ANNIndex.t()filename:
String.Filename of the index to be built.
Return
- retval:
bool
Python prototype (for reference only):
setOnDiskBuild(filename) -> retval
Initialize the random number generator with the given seed. Only necessary to pass this before adding the items. Will have no effect after calling build() or load().
Positional Arguments
self:
Evision.ANNIndex.t()seed:
integer().The given seed of the random number generator. Its value should be within the range of uint32_t.
Python prototype (for reference only):
setSeed(seed) -> None