Documentation
¶
Overview ¶
Package gann can be used for approximate nearest neighbor search.
By calling gann.CreateNewIndex function, we can obtain a search index. Its interface is defined in gann.Index:
type Index interface { GetANNbyItemID(id int64, searchNum int, bucketScale float64) (ann []int64, err error) GetANNbyVector(v []float64, searchNum int, bucketScale float64) (ann []int64, err error) }
GetANNbyItemID allows us to pass id of specific item for search execution and instead GetANNbyVector allows us to pass a vector.
See README.md for more details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index interface { // GetANNbyItemID ... search approximate nearest neighbors by a given itemID GetANNbyItemID(id int64, searchNum int, bucketScale float64) (ann []int64, err error) // GetANNbyVector ... search approximate nearest neighbors by a given query vector GetANNbyVector(v []float64, searchNum int, bucketScale float64) (ann []int64, err error) }
Index is the interface of gann's search index. GetANNbyItemID and GetANNbyVector are different in the form of query. GetANNbyItemID can be executed by passing a certain item's id contained in the list of items used in the index building phase. GetANNbyVector allows us to pass any vector of proper dimension.
searchNum is the number of requested approximated nearest neighbors, and bucketScale can be tuned to make balance between the search result's accuracy and computational complexity in the search phase.
see README.md for more details.
func CreateNewIndex ¶
CreateNewIndex build a new search index for given vectors. rawItems should consist of search target vectors and its slice index corresponds to the first argument id of GetANNbyItemID. For example, if we want to search approximate nearest neighbors of rawItems[3], it can simply achieved by calling index.GetANNbyItemID(3, ...).
dim is the dimension of target spaces. nTree and k are tunable parameters which affects performances of the index (see README.md for details.)
The last argument m is type of metric.Metric and represents the metric of the target search space. See https://godoc.org/github.com/mathetake/gann/metric for details.