E
- the type of data objects in the hash table.public class LSH<E> extends java.lang.Object implements NearestNeighborSearch<double[],E>, KNNSearch<double[],E>, RNNSearch<double[],E>, java.io.Serializable
By default, the query object (reference equality) is excluded from the neighborhood.
MPLSH
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<E> |
data
The data objects.
|
protected int |
H
The size of hash table.
|
protected java.util.List<Hash> |
hash
Hash functions.
|
protected int |
k
The number of random projections per hash value.
|
protected java.util.ArrayList<double[]> |
keys
The keys of data objects.
|
protected double |
w
The width of projection.
|
Constructor and Description |
---|
LSH(double[][] keys,
E[] data,
double w)
Constructor.
|
LSH(double[][] keys,
E[] data,
double w,
int H)
Constructor.
|
LSH(int d,
int L,
int k,
double w)
Constructor.
|
LSH(int d,
int L,
int k,
double w,
int H)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
initHashTable(int d,
int L,
int k,
double w,
int H)
Initialize the hash tables.
|
Neighbor<double[],E>[] |
knn(double[] q,
int k)
Search the k nearest neighbors to the query.
|
Neighbor<double[],E> |
nearest(double[] q)
Search the nearest neighbor to the given sample.
|
void |
put(double[] key,
E value)
Insert an item into the hash table.
|
void |
range(double[] q,
double radius,
java.util.List<Neighbor<double[],E>> neighbors)
Search the neighbors in the given radius of query object, i.e.
|
java.lang.String |
toString() |
protected java.util.ArrayList<double[]> keys
protected java.util.ArrayList<E> data
protected java.util.List<Hash> hash
protected int H
protected int k
protected double w
public LSH(double[][] keys, E[] data, double w)
keys
- the keys of data objects.data
- the data objects.w
- the width of random projections. It should be sufficiently
away from 0. But we should not choose an w value that is too large, which
will increase the query time.public LSH(double[][] keys, E[] data, double w, int H)
keys
- the keys of data objects.data
- the data objects.w
- the width of random projections. It should be sufficiently
away from 0. But we should not choose an w value that is too
large, which will increase the query time.H
- the size of universal hash tables.public LSH(int d, int L, int k, double w)
d
- the dimensionality of data.L
- the number of hash tables.k
- the number of random projection hash functions, which is usually
set to log(N) where N is the dataset size.w
- the width of random projections. It should be sufficiently
away from 0. But we should not choose an w value that is too
large, which will increase the query time.public LSH(int d, int L, int k, double w, int H)
d
- the dimensionality of data.L
- the number of hash tables.k
- the number of random projection hash functions, which is usually
set to log(N) where N is the dataset size.w
- the width of random projections. It should be sufficiently
away from 0. But we should not choose an w value that is too
large, which will increase the query time.H
- the size of universal hash tables.protected void initHashTable(int d, int L, int k, double w, int H)
public java.lang.String toString()
toString
in class java.lang.Object
public void put(double[] key, E value)
public Neighbor<double[],E> nearest(double[] q)
NearestNeighborSearch
nearest
in interface NearestNeighborSearch<double[],E>
q
- the query key.public Neighbor<double[],E>[] knn(double[] q, int k)
KNNSearch