public class RandomProjectionLSH<V extends Vec> extends Object implements VectorCollection<V>
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.
Modifier and Type | Class and Description |
---|---|
static class |
RandomProjectionLSH.RandomProjectionLSHFactory<V extends Vec> |
Modifier | Constructor and Description |
---|---|
|
RandomProjectionLSH(List<V> vecs,
int ints,
boolean inMemory)
Creates a new Random Projection LSH object that uses a full matrix of
normally distributed values.
|
|
RandomProjectionLSH(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.
|
protected |
RandomProjectionLSH(RandomProjectionLSH<V> toCopy)
Copy Constructor
|
Modifier and Type | Method and Description |
---|---|
VectorCollection<V> |
clone() |
int |
getSignatureBitLength()
Returns the signature or encoding length in bits.
|
List<? extends VecPaired<V,Double>> |
search(Vec query,
double range)
Searches the space for all vectors that are within a given range of the query vector.
|
List<? extends VecPaired<V,Double>> |
search(Vec query,
int neighbors)
Searches the space for the k neighbors that are closest to the given query vector
|
int |
size()
Returns the number of vectors stored in the collection
|
public RandomProjectionLSH(List<V> vecs, int ints, boolean inMemory)
vecs
- the list of vectors to form a collection forints
- the number of integers to use for the encodinginMemory
- 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.public RandomProjectionLSH(List<V> vecs, int ints, int poolSize)
vecs
- the list of vectors to form a collection forints
- the number of integers to use for the encodingpoolSize
- the number of normally distributed random variables to
store. Matrix values will be pulled on demand from an index in the pool
of values.protected RandomProjectionLSH(RandomProjectionLSH<V> toCopy)
toCopy
- the object to copypublic List<? extends VecPaired<V,Double>> search(Vec query, double range)
VectorCollection
search
in interface VectorCollection<V extends Vec>
query
- the vector we want to find others nearrange
- the search range around our querypublic List<? extends VecPaired<V,Double>> search(Vec query, int neighbors)
VectorCollection
search
in interface VectorCollection<V extends Vec>
query
- the vector we want to find neighbors ofneighbors
- the maximum number of neighbors to returnpublic int getSignatureBitLength()
public int size()
VectorCollection
size
in interface VectorCollection<V extends Vec>
public VectorCollection<V> clone()
Copyright © 2017. All rights reserved.