lsh

package
v0.0.0-...-15ac276 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IsAngularDistance int
	NPermutes         int
	NPlanes           int
	BiasMultiplier    float64
	DistanceThrsh     float64
	Dims              int
}

Config holds all needed constants for creating the Hasher instance

type Hasher

type Hasher struct {
	Config    Config
	Instances []HasherInstance
	Bias      float64
	MeanVec   blas64.Vector
	// contains filtered or unexported fields
}

Hasher holds N_PERMUTS number of HasherInstance instances

func New

func New(config Config) *Hasher

New creates slice of LSHIndexInstances to hold several permutations results

func (*Hasher) Dump

func (lshIndex *Hasher) Dump() ([]byte, error)

Dump encodes Hasher object as a byte-array

func (*Hasher) Generate

func (lshIndex *Hasher) Generate(convMean, convStd blas64.Vector) error

Generate method creates the lsh instances

func (*Hasher) GetDist

func (lshIndex *Hasher) GetDist(lv, rv blas64.Vector) (float64, bool)

GetDist measures the distance by specified distance metric

func (*Hasher) GetHashes

func (lshIndex *Hasher) GetHashes(vec blas64.Vector) map[int]uint64

GetHashes returns map of calculated lsh values for a given vector

func (*Hasher) Load

func (lshIndex *Hasher) Load(inp []byte) error

Load loads Hasher struct from the byte-array file

type HasherInstance

type HasherInstance struct {
	Planes []Plane
}

HasherInstance holds data for local sensetive hashing algorithm

func (*HasherInstance) GetHash

func (lshInstance *HasherInstance) GetHash(inpVec, meanVec blas64.Vector) uint64

GetHash calculates LSH code

type Plane

type Plane struct {
	Coefs blas64.Vector
	D     float64
}

Plane struct holds data needed to work with plane

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL