A simple, fixed-size bit set implementation.
A simple, fixed-size bit set implementation. This implementation is fast because it avoids safety/bound checking.
Lsh implementation as described in 'Randomized Algorithms and NLP: Using Locality Sensitive Hash Function for High Speed Noun Clustering' by Ravichandran et al.
Lsh implementation as described in 'Randomized Algorithms and NLP: Using Locality Sensitive Hash Function for High Speed Noun Clustering' by Ravichandran et al. See original publication for a detailed description of the parameters.
http://dl.acm.org/citation.cfm?id=1219917
Brute force O(n2) method to compute exact nearest neighbours. As this is a very expensive computation O(n2) an additional sample parameter may be passed such that neighbours are just computed for a random fraction.
Implementation based on approximated cosine distances.
Implementation based on approximated cosine distances. The cosine distances are approximated using hamming distances which are way faster to compute. Either the catalog matrix or the query matrix is broadcasted. This implementation is therefore suited for tasks where one of the matrices is very small (in order to be broadcastet) compared to the query matrix.
Standard Lsh implementation.
Standard Lsh implementation. The queryMatrix is hashed multiple times and exact hash matches are searched for in the dbMatrix. These candidates are used to compute the cosine distance.
Brute force O(size(query) * size(catalog)) method to compute exact nearest neighbours for rows in the query matrix.
Brute force O(size(query) * size(catalog)) method to compute exact nearest neighbours for rows in the query matrix. As this is a very expensive computation, additional sample parameters may be passed such that neighbours are just computed for a random fraction of the data set.
An id with it's hash encoding and original vector.
Represents an RDD from grouping items of its parent RDD in fixed size blocks by passing a sliding window over them.
Represents an RDD from grouping items of its parent RDD in fixed size blocks by passing a sliding window over them. The ordering is first based on the partition index and then the ordering of items within each partition. This is similar to sliding in Scala collections, except that it becomes an empty RDD if the window size is greater than the total number of items. It needs to trigger a Spark job if the parent RDD has more than one partitions. To make this operation efficient, the number of items per partition should be larger than the window size and the window size should be small, e.g., 2.
Int)*
Int)*
NOTE: both classes are copied from mllib and slightly modified since these classes are mllib private! Modified lines are marked with comments
An id with it's hash encoding.
interface defining similarity measurement between 2 vectors
implementation of VectorDistance that computes cosine similarity between two vectors
Compares two bit sets according to the first different bit
Compares two bit sets for their equality
Returns a string representation of a BitSet
Take distinct matrix entry values based on the indices only.
Take distinct matrix entry values based on the indices only. The actual values are discarded.
Returns the hamming distance between two bit vectors
Approximates the cosine distance of two bit sets using their hamming distance
Returns a local k by d matrix with random gaussian entries mean=0.0 and std=1.0
Returns a local k by d matrix with random gaussian entries mean=0.0 and std=1.0
This is a k by d matrix as it is multiplied by the input matrix
Converts a given input matrix to a bit set representation using random hyperplanes
Converts a given input matrix to a bit set representation using random hyperplanes
Converts a vector to a bit set by replacing all values of x with sign(x)