Hashing float vectors in N-dimensions
Go to file
Vitali Fedulov 53c0313311
Update README.md
2024-04-06 03:29:37 +02:00
LICENSE fnv.New64a test fix and README update 2024-02-07 20:55:42 +01:00
README.md Update README.md 2024-04-06 03:29:37 +02:00
cubes.go fnv.New64a test fix and README update 2024-02-07 20:55:42 +01:00
cubes_test.go switch to methods 2022-01-19 09:08:56 +01:00
go.mod first commit 2021-10-25 15:50:52 +02:00
hashes.go switch to methods 2022-01-19 09:08:56 +01:00
hashes_test.go fnv.New64a test fix and README update 2024-02-07 20:55:42 +01:00

README.md

Hashing N-dimensional float vectors

Search nearest neighbour vectors in n-dimensional space with hashes. There are no dependencies in this package.

The algorithm is based on the assumption that two real numbers can be considered equal within certain equality distance. Then quantization is used for comparison. To make sure points near or at quantization borders are also comparable, a vector can be discretized into more than one hash, as described here (also as PDF). The method indirectly clusters given vectors by hypercubes.

How to use

  1. Provided a float vector []float64, use CubeSet and CentralCube functions to generate hypercube coordinates []int. The difference between the two functions is that one corresponds to hash-table record and the other to a query or vice versa, depending on performance/memory preference.
  2. HashSet and DecimalHash/FNV1aHash are used to get corresponding hash set and central hash from the hypercube coordinates above. There are 2 alternative hash functions: DecimalHash and FNV1aHash. DecimalHash does not have collisions, but is not suitable for cases with large number of buckets or dimensions. FNV1aHash is applicable for all cases.

Example for similar image search and clustering.

Go doc for full code documentation.