## umap_from_knn()


Run UMAP on a precomputed k-nearest-neighbor graph.


Usage

``` python
umap_from_knn(
    indices,
    distances,
    *,
    n_components=2,
    min_dist=0.1,
    spread=1.0,
    n_epochs=None,
    learning_rate=1.0,
    init="auto",
    negative_sample_rate=5,
    repulsion_strength=1.0,
    local_connectivity=1.0,
    set_op_mix_ratio=1.0,
    a=None,
    b=None,
    random_state=None,
    optimizer=None,
    layout="0.6",
    disconnection_distance=None,
    n_threads=None,
    gpu=False,
    verbose=False
)
```


Use this when you already have neighbors, for example from [knn()](knn.md#polars_umap.knn), an exact search, a vector database or FAISS. The original vectors are not needed.


## Parameters


`indices: IntoExpr`  
`Array` or `List` column of integer row indices of each row's nearest neighbors, sorted by ascending distance. The row itself may be included (usually first, at distance 0) or left out. Every row must have the same number of neighbors.

`distances: IntoExpr`  
`Array` or `List` column with the matching distances.

`n_components: int = ``2`  

`min_dist: int = ``2`  

`spread: int = ``2`  

`n_epochs: int = ``2`  

`learning_rate: int = ``2`  

`negative_sample_rate: int = ``2`  

`repulsion_strength: float = ``1.0`  

`local_connectivity: float = ``1.0`  

`set_op_mix_ratio: float = ``1.0`  

`a: float = ``1.0`  

`b: float = ``1.0`  

`random_state: float = ``1.0`  

`optimizer: Optimizer | None = None`  
See [umap()](umap.md#polars_umap.umap).

`layout: Optimizer | None = None`  
See [umap()](umap.md#polars_umap.umap).

`disconnection_distance: Optimizer | None = None`  
See [umap()](umap.md#polars_umap.umap).

`n_threads: Optimizer | None = None`  
See [umap()](umap.md#polars_umap.umap).

`gpu: Optimizer | None = None`  
See [umap()](umap.md#polars_umap.umap).

`verbose: Optimizer | None = None`  
See [umap()](umap.md#polars_umap.umap).

`init: InitLike = ``"auto"`  
See [umap()](umap.md#polars_umap.umap). `"pca"` is not available because it needs the vectors.


## Returns


`pl.Expr`  
An `Array(Float32, n_components)` expression.
