Package org.ddogleg.nn
Class FactoryNearestNeighbor
java.lang.Object
org.ddogleg.nn.FactoryNearestNeighbor
Factory for creating implementations of
NearestNeighbor
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <P> NearestNeighbor<P>
exhaustive
(KdTreeDistance<P> distance) Performs an optimalNearestNeighbor
by exhaustively consider all possible solutions.static <P> NearestNeighbor<P>
generic
(ConfigNearestNeighborSearch config, KdTreeDistance<P> distance) Factory for genericNearestNeighbor
.static <P> NearestNeighbor<P>
kdRandomForest
(KdTreeDistance<P> distance, int maxNodesSearched, int numTrees, int numConsiderSplit, long randomSeed) ApproximateNearestNeighbor
search which uses a set of randomly generated K-D trees and a Best-Bin-First search.static <P> NearestNeighbor<P>
kdtree
(KdTreeDistance<P> distance) Performs an optimalNearestNeighbor
search using K-D tree.static <P> NearestNeighbor<P>
kdtree
(KdTreeDistance<P> distance, int maxNodesSearched) Performs an approximateNearestNeighbor
search using K-D tree.static NearestNeighbor<double[]>
vptree
(long randSeed) Vantage point
tree implementation for nearest neighbor search.
-
Constructor Details
-
FactoryNearestNeighbor
public FactoryNearestNeighbor()
-
-
Method Details
-
generic
public static <P> NearestNeighbor<P> generic(ConfigNearestNeighborSearch config, KdTreeDistance<P> distance) Factory for genericNearestNeighbor
. -
kdtree
Performs an optimalNearestNeighbor
search using K-D tree. Distance measure is Euclidean squared.- Type Parameters:
P
- Point type.- Parameters:
distance
- Specifies how distance is computed between two points.- Returns:
NearestNeighbor
implementation- See Also:
-
kdtree
Performs an approximateNearestNeighbor
search using K-D tree. Node are searched in Best-Bin-First order. Distance measure is Euclidean squared.- Type Parameters:
P
- Point type.- Parameters:
maxNodesSearched
- Maximum number of nodes it will search. Controls speed and accuracy.distance
- Specifies how distance is computed between two points.- Returns:
NearestNeighbor
implementation- See Also:
-
kdRandomForest
public static <P> NearestNeighbor<P> kdRandomForest(KdTreeDistance<P> distance, int maxNodesSearched, int numTrees, int numConsiderSplit, long randomSeed) ApproximateNearestNeighbor
search which uses a set of randomly generated K-D trees and a Best-Bin-First search. Designed to work in high dimensional space. Distance measure is Euclidean squared.- Type Parameters:
P
- Point type.- Parameters:
distance
- Specifies how distance is computed between two points.maxNodesSearched
- Maximum number of nodes it will search. Controls speed and accuracy.numTrees
- Number of trees that are considered. Try 10 and tune.numConsiderSplit
- Number of nodes that are considered when generating a tree. Must be less than the point's dimension. Try 5randomSeed
- Seed used by random number generator- Returns:
NearestNeighbor
implementation- See Also:
-
exhaustive
Performs an optimalNearestNeighbor
by exhaustively consider all possible solutions. Distance measure is Euclidean squared.- Parameters:
distance
- Specifies how distance is computed between two points.- Returns:
NearestNeighbor
implementation- See Also:
-
vptree
Vantage point
tree implementation for nearest neighbor search. Slower than KD-Tree on random data, but faster than it for some pathological cases.- Parameters:
randSeed
- Random seed- Returns:
NearestNeighbor
implementation- See Also:
-