Package org.ddogleg.nn
Class FactoryNearestNeighbor
java.lang.Object
org.ddogleg.nn.FactoryNearestNeighbor
Factory for creating implementations of
NearestNeighbor.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <P> NearestNeighbor<P>exhaustive(KdTreeDistance<P> distance) Performs an optimalNearestNeighborby 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) ApproximateNearestNeighborsearch 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 optimalNearestNeighborsearch using K-D tree.static <P> NearestNeighbor<P>kdtree(KdTreeDistance<P> distance, int maxNodesSearched) Performs an approximateNearestNeighborsearch using K-D tree.static NearestNeighbor<double[]>vptree(long randSeed) Vantage pointtree 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 optimalNearestNeighborsearch 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:
NearestNeighborimplementation- See Also:
-
kdtree
Performs an approximateNearestNeighborsearch 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:
NearestNeighborimplementation- See Also:
-
kdRandomForest
public static <P> NearestNeighbor<P> kdRandomForest(KdTreeDistance<P> distance, int maxNodesSearched, int numTrees, int numConsiderSplit, long randomSeed) ApproximateNearestNeighborsearch 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:
NearestNeighborimplementation- See Also:
-
exhaustive
Performs an optimalNearestNeighborby exhaustively consider all possible solutions. Distance measure is Euclidean squared.- Parameters:
distance- Specifies how distance is computed between two points.- Returns:
NearestNeighborimplementation- See Also:
-
vptree
Vantage pointtree 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:
NearestNeighborimplementation- See Also:
-