KmknnParam | R Documentation |
A class to hold parameters for the k-means k-nearest-neighbors (KMKNN) algorithm for exact nearest neighbor identification.
KmknnParam(..., distance = c("Euclidean", "Manhattan", "Cosine"))
## S4 method for signature 'KmknnParam'
defineBuilder(BNPARAM)
... |
Further arguments, ignored. |
distance |
String specifying the distance metric to use. Cosine distances are implemented as Euclidean distances on L2-normalized coordinates. |
BNPARAM |
A KmknnParam instance. |
In the KMKNN algorithm (Wang, 2012), k-means clustering is first applied to the data points using the square root of the number of points as the number of cluster centers. The cluster assignment and distance to the assigned cluster center for each point represent the KMKNN indexing information. This speeds up the nearest neighbor search by exploiting the triangle inequality between cluster centers, the query point and each point in the cluster to narrow the search space. The advantage of the KMKNN approach is its simplicity and minimal overhead, resulting in performance improvements over conventional tree-based methods for high-dimensional data where most points need to be searched anyway. It is also trivially extended to find all neighbors within a threshold distance from a query point.
Note that KMKNN operates much more naturally with Euclidean distances.
Computational efficiency may not be optimal when using it with other choices of distance
, though the results will still be exact.
The KmknnParam
constructor returns an instance of the KmknnParam class.
The defineBuilder
method returns a list that can be used in buildIndex
to construct a KMKNN index.
Aaron Lun, using code from the cydar package.
Wang X (2012). A fast exact k-nearest neighbors algorithm for high dimensional search using k-means clustering and triangle inequality. Proc Int Jt Conf Neural Netw, 43, 6:2351-2358.
BiocNeighborParam, for the parent class and its available methods.
(out <- KmknnParam(iter.max=100))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.