Class Hash

java.lang.Object
smile.neighbor.lsh.Hash
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MultiProbeHash

public class Hash extends Object implements Serializable
The hash function for Euclidean spaces.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Hash(int d, int k, double w, int H)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int index, double[] x)
    Insert an item into the hash table.
    get(double[] x)
    Returns the bucket entry for the given point.
    get(int i)
    Returns the bucket entry for the given hash value.
    int
    hash(double[] x)
    Apply hash functions on given vector x.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Hash

      public Hash(int d, int k, double w, int H)
      Constructor.
      Parameters:
      d - the dimensionality of data.
      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 a w value that is too large, which will increase the query time.
      H - the size of universal hash tables.
  • Method Details

    • hash

      public int hash(double[] x)
      Apply hash functions on given vector x.
      Parameters:
      x - the vector to be hashed.
      Returns:
      the bucket of hash table for given vector x.
    • add

      public void add(int index, double[] x)
      Insert an item into the hash table.
      Parameters:
      index - the index of point in the data set.
      x - the data point.
    • get

      public Bucket get(int i)
      Returns the bucket entry for the given hash value.
      Parameters:
      i - the hash code.
      Returns:
      the bucket.
    • get

      public Bucket get(double[] x)
      Returns the bucket entry for the given point.
      Parameters:
      x - the data point.
      Returns:
      the bucket.