# `Scholar.Neighbors.LargeVis`
[🔗](https://github.com/elixir-nx/scholar/blob/main/lib/scholar/neighbors/large_vis.ex#L1)

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

  * [Visualizing Large-scale and High-dimensional Data](https://arxiv.org/abs/1602.00370).

# `expand`
[🔗](https://github.com/elixir-nx/scholar/blob/main/lib/scholar/neighbors/large_vis.ex#L142)

# `fit`
[🔗](https://github.com/elixir-nx/scholar/blob/main/lib/scholar/neighbors/large_vis.ex#L94)

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]
      ]
    >

---

*Consult [api-reference.md](api-reference.md) for complete listing*
