Class FactoryNearestNeighbor

java.lang.Object
org.ddogleg.nn.FactoryNearestNeighbor

public class FactoryNearestNeighbor extends Object
Factory for creating implementations of NearestNeighbor.
  • Constructor Details

    • FactoryNearestNeighbor

      public FactoryNearestNeighbor()
  • Method Details

    • generic

      public static <P> NearestNeighbor<P> generic(ConfigNearestNeighborSearch config, KdTreeDistance<P> distance)
      Factory for generic NearestNeighbor.
    • kdtree

      public static <P> NearestNeighbor<P> kdtree(KdTreeDistance<P> distance)
      Performs an optimal NearestNeighbor 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

      public static <P> NearestNeighbor<P> kdtree(KdTreeDistance<P> distance, int maxNodesSearched)
      Performs an approximate NearestNeighbor 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)
      Approximate NearestNeighbor 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 5
      randomSeed - Seed used by random number generator
      Returns:
      NearestNeighbor implementation
      See Also:
    • exhaustive

      public static <P> NearestNeighbor<P> exhaustive(KdTreeDistance<P> distance)
      Performs an optimal NearestNeighbor 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

      public static NearestNeighbor<double[]> vptree(long randSeed)
      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: