row2vec

Low-dimensional vector embeddings for tabular data — neural and classical methods behind one interface.

MIT·Python 3.10–3.12·GitHub·PyPI·Documentation

A table row is an awkward object: some columns are numbers on incompatible scales, others are categories, and some values are missing altogether. Most of what one wants to do with rows — cluster them, find the near neighbours of one, feed them to a model, plot them — presupposes that they are already points in a metric space. Row2Vec performs that conversion. It takes a DataFrame and returns one dense numeric vector per row, handling the scaling, encoding, and imputation on the way, and it offers both neural and classical methods behind a single call.

Installation

pip install row2vec

Example

import pandas as pd
from row2vec import learn_embedding

df = pd.read_csv("customers.csv")   # mixed types, some values missing
embeddings = learn_embedding(df, mode="pca", embedding_dim=5)

embeddings.shape                    # (len(df), 5)

The returned object is a DataFrame of the same length as the input, indexed alike, with one column per embedding dimension. Choosing a different method is a change of the mode argument — "unsupervised", "tsne", "umap", "target", "contrastive" — and the call site does not otherwise change.

The embedding

numeric column categorical column embedded row
Figure 1. Each row of the table (left) — a mix of numeric and categorical fields — becomes a single point in a low-dimensional space (right). Rows that resemble one another end up near one another, which is what makes the output usable for clustering, retrieval, and visualisation.

Methods

ModeAppropriate whenParameter
pcaa fast linear baseline with interpretable components is wantedembedding_dim
unsupervisedthe structure is non-linear and an autoencoder is warrantedhidden_units, max_epochs
tsnethe goal is a two- or three-dimensional plot of local structureperplexity
umaplocal and global structure are both to be preservedn_neighbors, min_dist
targetone vector per category of a column is wanted, not per rowreference_column
contrastivepairs known to be alike or unalike are available for supervisionauto_pairs, margin

What is handled for you

  • Missing values. the pattern of missingness is analysed and an imputation strategy chosen per column.
  • Categorical fields. encoded by a strategy selected from the column's cardinality — one-hot, ordinal, target, or learned entity embeddings.
  • Scale. numeric columns are standardised; the output can additionally be scaled to a fixed range.
  • Architecture. for the neural modes, the layer widths and the embedding dimension can be searched rather than guessed.

Documentation

Citation

@software{tresoldi_row2vec_2026,
  author  = {Tresoldi, Tiago},
  title   = {Row2Vec: Neural and classical embeddings
             for tabular data},
  year    = {2026},
  version = {0.2.0},
  url     = {https://github.com/tresoldi/row2vec}
}