Cosine/Simhash locality sensitive hashing (LSH) in Golang with Euclidean distance sort
Implements Random projection LSH https://en.wikipedia.org/wiki/Locality-sensitive_hashing#Random_projection
Use go tool to install the package in your packages tree:
go get github.com/cogile/simhash-lshImport package as:
import "github.com/cogile/simhash-lsh"func main() {
lsh := simhashlsh.NewCosineLsh(8, 1, 6)
lsh.Insert([]float64{1, 2, 3, 4, 5, 6, 7, 8}, "1")
lsh.Insert([]float64{2, 3, 4, 5, 6, 7, 8, 9}, "2")
lsh.Insert([]float64{10, 12, 99, 1, 5, 31, 2, 3}, "3")
fmt.Println(lsh.Query([]float64{1, 2, 3, 4, 5, 6, 7, 7}))
// [{[1 2 3 4 5 6 7 8] 1} {[2 3 4 5 6 7 8 9] 2}]
}