createns
Function File: obj = createns (X)
Function File: obj = createns (X, name, value, …)
Create a nearest neighbor searcher object.
obj = createns (X) creates a nearest neighbor searcher
object using the training data X. By default, it constructs an
ExhaustiveSearcher object with the Euclidean distance metric.
obj = createns (X, name, value, …)
allows customization of the searcher type and its properties through
name-value pairs. The following name-value pair is supported to specify
the searcher type:
| Name | Value | |
|---|---|---|
"NSMethod" | Specifies the nearest neighbor search
method. Possible values are:
Default is |
Additional name-value pairs depend on the selected "NSMethod" and
are passed directly to the constructor of the corresponding class:
"exhaustive", see ExhaustiveSearcher documentation
for parameters like "Distance", "P", "Scale", and
"Cov".
"kdtree", see KDTreeSearcher documentation for
parameters like "Distance", "P", and "BucketSize".
"hnsw", see hnswSearcher documentation for parameters
like "Distance", "P", "Scale", "Cov",
"MaxNumLinksPerNode", and "TrainSetSize".
Input Arguments:
Output:
ExhaustiveSearcher, KDTreeSearcher, or hnswSearcher,
depending on the specified "NSMethod".
Examples:
## Create an ExhaustiveSearcher with default parameters X = [1, 2; 3, 4; 5, 6]; obj = createns (X); ## Create a KDTreeSearcher with Euclidean distance obj = createns (X, "NSMethod", "kdtree", "Distance", "euclidean"); ## Create an hnswSearcher with Minkowski distance and custom parameters obj = createns (X, "NSMethod", "hnsw", "Distance", "minkowski", "P", 3, "MaxNumLinksPerNode", 2); |
See also: ExhaustiveSearcher, KDTreeSearcher, hnswSearcher, knnsearch, rangesearch
Source Code: createns