Skip to main content

UmapExprNamespace

UMAP and nearest neighbor search on an expression.

Usage

Source

UmapExprNamespace(expr)

Available as pl.col(...).umap after import polars_umap.

Methods

Name Description
fit_transform() Embed this column with UMAP. Takes the same parameters as polars_umap.umap().
from_knn() UMAP on a precomputed kNN graph, with this expression as the indices.
knn() Approximate k nearest neighbors. Takes the same parameters as polars_umap.knn().

fit_transform()

Embed this column with UMAP. Takes the same parameters as polars_umap.umap().

Usage

Source

fit_transform(**params)
Examples
>>> import polars as pl
>>> import polars_umap  # noqa: F401
>>> df = pl.DataFrame({"v": [[float(i), float(i % 5), float(i % 3)] for i in range(50)]})
>>> out = df.select(pl.col("v").umap.fit_transform(random_state=0))
>>> out.schema["v"] == pl.Array(pl.Float32, 2)

True


from_knn()

UMAP on a precomputed kNN graph, with this expression as the indices.

Usage

Source

from_knn(distances, **params)

knn()

Approximate k nearest neighbors. Takes the same parameters as polars_umap.knn().

Usage

Source

knn(**params)