Skip to contents

This function generates various sensible default parameters for all of the different approximate nearest neighbours that are available within this package.

Usage

params_knn_defaults()

Value

A named list with the following elements:

  • k - Integer. Number of neighbours. Defaults to 15L.

  • knn_method - String. Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly. One of c("kmknn", "hnsw", "annoy", "nndescent", "ivf", "exhaustive"). Defaults to "kmknn".

  • ann_dist - String. Which distance metric to use for the approximate nearest neighbour search. One of c("euclidean", "cosine"). Defaults to "euclidean".

  • n_trees - Integer. Annoy param: number of trees to generate for Annoy. Defaults to 50L.

  • search_budget - Integer or NULL. Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20L. Defaults to NULL.

  • delta - Numeric. NNDescent param: early termination criterium for NNDescent. Defaults to 0.001.

  • diversify_prob - Numeric. NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN. Defaults to 0.0.

  • ef_budget - Integer or NULL. NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN. Defaults to NULL.

  • m - Integer. HNSW param: number of connections between layers for HNSW. Defaults to 16L.

  • ef_construction - Integer. HNSW param: size of dynamic candidate list during construction. Defaults to 200L.

  • ef_search - Integer. HNSW param: size of candidate list (higher = better recall, slower). Defaults to 100L.

  • n_list - Integer or NULL. IVF param: number of clusters/centroids to generate. NULL generates sqrt(n) lists. Defaults to NULL.

  • n_probe - Integer or NULL. IVF param: number of clusters/centroids to query. NULL queries sqrt(n_lists) clusters. Defaults to NULL.