Package smile.neighbor
Interface KNNSearch<K,V>
- Type Parameters:
K
- the type of keys.V
- the type of associated objects.
- All Known Implementing Classes:
CoverTree
,KDTree
,LinearSearch
,LSH
,MPLSH
,MutableLSH
public interface KNNSearch<K,V>
Retrieves the top k nearest neighbors to the query. This technique is
commonly used in predictive analytics to estimate or classify a point
based on the consensus of its neighbors. K-nearest neighbor graphs are
graphs in which every point is connected to its k nearest neighbors.
-
Method Summary
-
Method Details
-
nearest
Returns the nearest neighbor. In machine learning, we often build a nearest neighbor search data structure, and then search with object in the same dataset. The object itself is of course the nearest one with distance 0. Since this is generally useless, we check the reference during the search and excludes the query object from the results.- Parameters:
q
- the query key.- Returns:
- the nearest neighbor
-
search
Retrieves the k nearest neighbors to the query key.- Parameters:
q
- the query key.k
- the number of nearest neighbors to search for.- Returns:
- the k nearest neighbors
-