Skip to main content

UMAP

UDTF: cuml_umap

Official cuML reference: Python API

cuML UMAP fits a deterministic, query-local manifold embedding for dense feature rows.

Quickstart​

Register the relations referenced by the parenthesized SELECT clauses below. For metadata validation, the descriptor names input_vectors.

SELECT id, dim_0, dim_1
FROM cuml_umap(
input => (SELECT id, d0, d1 FROM t),
n_neighbors => 5
)
ORDER BY row_ordinal;

Inputs​

Each relation argument is a parenthesized SELECT subquery. Metadata validation resolves a registered table or view for the same role without scanning its rows. See ML Inputs for the ID, feature element, Float64 narrowing, null, finite-value, and runtime-dimension contract.

RoleRequiredValidation referenceDescription
inputyestableDense feature rows evaluated by the call.

Vector element types​

Feature values must be Float32 or Float64.

Arguments and options​

Scalar SQL arguments​

ArgumentTypeRequiredDefaultConstraintsDescription
initstringno"spectral"one of "spectral", "random"Embedding initialization method.
learning_ratenumberno1greater than 0Positive embedding optimization rate.
local_connectivitynumberno1minimum 0Local connectivity adjustment.
min_distnumberno0.1minimum 0Minimum distance between embedded points; at most spread.
n_componentsintegerno2minimum 1; maximum 2147483647Number of embedding dimensions.
n_epochsintegerno0minimum 0; maximum 2147483647Optimization epochs; zero selects the native default.
n_neighborsintegerno15minimum 1; maximum 2147483647Number of neighbors used to construct the manifold.
negative_sample_rateintegerno5minimum 1; maximum 2147483647Negative samples per positive edge.
random_stateintegerno0minimum 0; maximum 18446744073709551615Seed for reproducible initialization.
repulsion_strengthnumberno1minimum 0Repulsive force applied during optimization.
set_op_mix_rationumberno1minimum 0; maximum 1Fuzzy-set intersection/union mix in [0, 1].
spreadnumberno1greater than 0Positive scale for embedded point distances.

Vector binding shapes​

Each relation subquery projects an id and either feature columns in dimension order or one list column, with the element types listed under Vector element types. Nullable field types are accepted. A null ID, feature value, list row, or list element fails the query.

The list-column shape excludes other feature columns. See ML Inputs for the allowed list containers and runtime checks.

Output​

ColumnTypeNullableDescription
row_ordinalUInt64noEvaluated input row position, including when IDs repeat. Follows the input's top-level ORDER BY on output columns; unspecified without one.
idsame_as_input.idnoLogical input ID.
dim_<index>Float32noEmbedded dimension value, repeated n_components times. The output contains n_components such columns, dim_0 through dim_&lt;n_components - 1&gt;.

The output schema depends on the call. Run gpu_validate_call against registered relations to inspect the schema that the validated ID types and literal options produce.

Examples​

Can projected reviews be connected back to their original text?​

This query projects 9,967 sampled low-rating headphone reviews from 1,024 dimensions and joins the output IDs to product names and review text.

SELECT u.id, u.dim_0, u.dim_1, r.product_id,
p.title AS product_title, EXTRACT(YEAR FROM r.review_time) AS review_year,
r.rating, r.title, r.embedding_text
FROM cuml_umap(
input => (SELECT v.id, v.vector
FROM semantic_reviews_vectors v
JOIN semantic_reviews_text r ON r.id = v.id
WHERE r.category_l3 = 'Headphones & Earbuds' AND v.sample_rank < 100000
ORDER BY v.id),
n_components => 2, n_neighbors => 30, min_dist => 0.1, random_state => 42) u
JOIN semantic_reviews_text r ON r.id = u.id
JOIN products p ON p.product_id = r.product_id
ORDER BY u.id

The first three records of the saved projection show the returned coordinates with the rating and year of each review. The saved sample keeps review IDs, coordinates, ratings and years; the review text stays in the source dataset.

Review IDxyRatingYear
2017-2.537-1.04322021
74699-4.518-1.80712021
108772-1.4542.55822022

UMAP's output is a relation that can be joined to the review records in the same query, allowing reviewers to inspect the underlying review text alongside projection coordinates.

The capture records the query and the fixed 1,200-record website sample drawn from its 9,967 rows.

Limits​

  • L2SqrtExpanded distance, brute-force kNN, and deterministic mode are fixed.
  • Float64 features, as wide columns or list elements, are narrowed to Float32 on the device before training or inference. Each value rounds to the nearest Float32, which keeps about seven significant digits; a value beyond the Float32 range becomes infinite and fails the query.
  • Empty input returns an empty result. Other inputs require n_neighbors < rows, checked at execution.
  • min_dist must not exceed spread. The fit and embedding are query-local.
  • random_state seeds the spectral initialization, the edge shuffle, and negative sampling.