Documentation of 'jsat.linear.vectorcollection.lsh.RandomProjectionLSH' Java class
RandomProjectionLSH
jsat.linear.vectorcollection.lsh

Class RandomProjectionLSH<V extends Vec>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, VectorCollection<V>


    public class RandomProjectionLSH<V extends Vec>
    extends java.lang.Object
    implements VectorCollection<V>
    An implementation of Locality Sensitive Hashing for the CosineDistance using random projections. This forms a vector collection that performs a linear search of the data set, but does so in a more efficient manner by comparing hamming distances in a byte array. However, the reported distances are only approximations - and may not be correct. For this reason the results are also approximate.

    See:
    • Charikar, M. S. (2002). Similarity estimation techniques from rounding algorithms. Proceedings of the thiry-fourth annual ACM symposium on Theory of computing - STOC ’02 (pp. 380–388). New York, New York, USA: ACM Press. doi:10.1145/509907.509965
    • Durme, B. Van,&Lall, A. (2010). Online Generation of Locality Sensitive Hash Signatures. Proceedings of the ACL 2010 Conference Short Papers (pp. 231–235). Stroudsburg, PA, USA.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      RandomProjectionLSH(java.util.List<V> vecs, int ints, boolean inMemory)
      Creates a new Random Projection LSH object that uses a full matrix of normally distributed values.
      RandomProjectionLSH(java.util.List<V> vecs, int ints, int poolSize)
      Creates a new Random Projection LSH object that uses a pool of normally distributed values to approximate a full matrix with considerably less memory storage.
    • Constructor Detail

      • RandomProjectionLSH

        public RandomProjectionLSH(java.util.List<V> vecs,
                                   int ints,
                                   boolean inMemory)
        Creates a new Random Projection LSH object that uses a full matrix of normally distributed values.
        Parameters:
        vecs - the list of vectors to form a collection for
        ints - the number of integers to use for the encoding
        inMemory - true to construct the full matrix in memory, or false to construct the needed values on demand. This reduces memory use at increased CPU usage.
      • RandomProjectionLSH

        public RandomProjectionLSH(java.util.List<V> vecs,
                                   int ints,
                                   int poolSize)
        Creates a new Random Projection LSH object that uses a pool of normally distributed values to approximate a full matrix with considerably less memory storage.
        Parameters:
        vecs - the list of vectors to form a collection for
        ints - the number of integers to use for the encoding
        poolSize - the number of normally distributed random variables to store. Matrix values will be pulled on demand from an index in the pool of values.
    • Method Detail

      • build

        public void build(boolean parallel,
                          java.util.List<V> collection,
                          DistanceMetric dm)
        Description copied from interface: VectorCollection
        Builds this metric index from the given collection of points using the given distance metric.
        Specified by:
        build in interface VectorCollection<V extends Vec>
        Parameters:
        parallel - true if the index should be built in parallel, or false if it should be done in a single thread.
        collection - the list of vectors to put into the index
        dm - the distance metric to build the index using.
      • search

        public void search(Vec query,
                           double range,
                           java.util.List<java.lang.Integer> neighbors,
                           java.util.List<java.lang.Double> distances)
        Description copied from interface: VectorCollection
        Performs a range search of the current collection. The index and distance of each found neighbor will be placed into the given Lists.
        Specified by:
        search in interface VectorCollection<V extends Vec>
        Parameters:
        query - the point to search for the neighbors within a given radius.
        range - the radius to search for all the neighbors with a distance ≤ range.
        neighbors - the list to store the index of the neighbors in. Will be sorted by distance to the query, and paired with the values in distances.
        distances - the list to store the distance of the neighbors to the query in. Will be sorted, and paired with the values in neighbors.
      • search

        public void search(Vec query,
                           int numNeighbors,
                           java.util.List<java.lang.Integer> neighbors,
                           java.util.List<java.lang.Double> distances)
        Description copied from interface: VectorCollection
        Performs k-Nearest Neighbor search of the current collection. The index and distance of each found neighbor will be placed into the given Lists.
        Specified by:
        search in interface VectorCollection<V extends Vec>
        Parameters:
        query - the point to search for the k-nearest neighbors of
        numNeighbors - the number of neighbors k to search for.
        neighbors - the list to store the index of the neighbors in. Will be sorted by distance to the query, and paired with the values in distances.
        distances - the list to store the distance of the neighbors to the query in. Will be sorted, and paired with the values in neighbors.
      • getSignatureBitLength

        public int getSignatureBitLength()
        Returns the signature or encoding length in bits.
        Returns:
        the signature length in bits
      • size

        public int size()
        Description copied from interface: VectorCollection
        Returns the number of vectors stored in the collection
        Specified by:
        size in interface VectorCollection<V extends Vec>
        Returns:
        the size of the collection
      • get

        public V get(int indx)
        Description copied from interface: VectorCollection
        Accesses a vector from this collection via index.
        Specified by:
        get in interface VectorCollection<V extends Vec>
        Parameters:
        indx - the index in [0, VectorCollection.size()) of the vector to access
        Returns:
        the vector from the collection

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.