hnswSearcher
Hierarchical Navigable Small Worlds (HNSW) approximate nearest neighbor search
Since R2024a
Description
An hnswSearcher
model object stores the training data, distance
metric, and parameter values of the distance metric for a Hierarchical Navigable Small Worlds
(HNSW) approximate nearest neighbor search. For an algorithm overview, see Approximate KNN Search Using Hierarchical Navigable Small Worlds (HNSW) Algorithm.
After you create an hnswSearcher
model object, you can use it to find
points in the training data that are close to the query data by performing a nearest neighbor
search using knnsearch
. The HNSW search algorithm is faster than
other KNN search algorithms. However, HNSW search results might not be exact.
Creation
Description
creates an HNSW searcher object based on the data in the matrix Mdl
= hnswSearcher(X
)X
. Each
row of X
represents one observation, and each column represents one
feature.
sets Properties and additional options
using name-value arguments. For example, to use the Minkowski distance, set
Mdl
= hnswSearcher(X
,Name=Value
)Distance="minkowski"
.
Input Arguments
Properties
Object Functions
knnsearch | Find k-nearest neighbors using searcher object |
Examples
Algorithms
The HNSW algorithm is described in Malkov and Yashunin [1]. A brief description of the algorithm appears in Approximate KNN Search Using Hierarchical Navigable Small Worlds (HNSW) Algorithm.
Alternative Functionality
You can also create an HNSW searcher object by using createns
with the specification NSMethod="hnsw"
. The
resulting object is the same as the object you create using the
hnswSearcher
function.
References
[1] Malkov, Yu. A., and D. A. Yashunin. Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs. Available at https://arxiv.org/abs/1603.09320.
Version History
Introduced in R2024a