Class RandomProjectionTree

java.lang.Object
smile.neighbor.RandomProjectionTree
All Implemented Interfaces:
KNNSearch<double[],double[]>

public class RandomProjectionTree extends Object implements KNNSearch<double[],double[]>
Random projection trees. The Random Projection Tree structures are space partitioning data structures that automatically adapt to various notions of intrinsic dimensionality of data.
  • Method Details

    • search

      public Neighbor<double[],double[]>[] search(double[] q, int k)
      Description copied from interface: KNNSearch
      Retrieves the k nearest neighbors to the query key.
      Specified by:
      search in interface KNNSearch<double[],double[]>
      Parameters:
      q - the query key.
      k - the number of nearest neighbors to search for.
      Returns:
      the k nearest neighbors
    • numNodes

      public int numNodes()
      Returns the number of nodes in the tree.
      Returns:
      the number of nodes in the tree.
    • numLeaves

      public int numLeaves()
      Returns the number of leaf nodes in the tree.
      Returns:
      the number of leaf nodes in the tree.
    • leafSamples

      public List<int[]> leafSamples()
      Returns the list of samples in each leaf node.
      Returns:
      the list of samples in each leaf node.
    • of

      public static RandomProjectionTree of(double[][] data, int leafSize, boolean angular)
      Builds a random projection tree.
      Parameters:
      data - the data set.
      leafSize - The maximum size of leaf node.
      angular - true for angular metric, otherwise Euclidean.
      Returns:
      A random projection tree.