View Source Scholar.Neighbors.LargeVis (Scholar v0.3.1)
LargeVis algorithm for approximate k-nearest neighbor (k-NN) graph construction.
The algorithms works in the following way. First, the approximate k-NN graph is constructed using a random projection forest. Then, the graph is refined by looking at the neighbors of neighbors of every point for a fixed number of iterations. This step is called NN-expansion.
References
Summary
Functions
Constructs the approximate k-NN graph with LargeVis.
Functions
Constructs the approximate k-NN graph with LargeVis.
Returns neighbor indices and distances.
Examples
iex> key = Nx.Random.key(12)
iex> tensor = Nx.iota({5, 2})
iex> {graph, distances} = Scholar.Neighbors.LargeVis.fit(tensor, num_neighbors: 2, metric: :squared_euclidean, min_leaf_size: 2, num_trees: 3, key: key)
iex> graph
#Nx.Tensor<
u32[5][2]
[
[0, 1],
[1, 0],
[2, 1],
[3, 2],
[4, 3]
]
>
iex> distances
#Nx.Tensor<
f32[5][2]
[
[0.0, 8.0],
[0.0, 8.0],
[0.0, 8.0],
[0.0, 8.0],
[0.0, 8.0]
]
>