尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证A Python library for easily generating low-dimensional vector embeddings from tabular datasets
翻译准备中
取自仓库 README
正在加载完整 README。 以下为已保存的摘录。
Turn table rows into vectors.
Row2Vec takes a DataFrame whose columns are a mix of numbers, categories, and
missing values, and returns one dense numeric vector per row. The scaling,
encoding, and imputation are handled for you, and both neural and classical
methods sit behind the same call.查看完整 README ↗Turn table rows into vectors.
Row2Vec takes a DataFrame whose columns are a mix of numbers, categories, and
missing values, and returns one dense numeric vector per row. The scaling,
encoding, and imputation are handled for you, and both neural and classical
methods sit behind the same call.
import row2vec
df = row2vec.generate_synthetic_data(200) # mixed numeric + categorical columns
embeddings = row2vec.learn_embedding(df, mode="pca", embedding_dim=3)
assert embeddings.shape == (200, 3) # one row in, one vector out
That is the whole point: everything downstream of a table — clustering, nearest-neighbour lookup, a scatter plot, a feature for another model — presupposes that rows are already points in a metric space. Getting them there usually means a hand-rolled pipeline of encoders, scalers, and imputers. Row2Vec is that pipeline, with several well-tested ways to do the projection itself behind one consistent interface.
pip install row2vec # PCA, t-SNE, UMAP
pip install "row2vec[neural]" # adds the autoencoder, target and contrastive modes (TensorFlow)
The default install is light and has no TensorFlow. The neural modes
(unsupervised, target, contrastive), architecture search, and entity
embeddings for very high-cardinality columns need the neural extra; asking for
one without it raises an error that says so.
One function does the work. Swapping methods means changing mode; the call
site never changes.
import row2vec
df = row2vec.generate_synthetic_data(150)
pca = row2vec.learn_embedding(df, mode="pca", embedding_dim=2)
tsne = row2vec.learn_embedding(df, mode="tsne", embedding_dim=2, perplexity=10)
assert pca.shape == tsne.shape == (150, 2)
assert list(pca.index) == list(df.index) # aligned with the input frame
The result is a DataFrame of the same length as the input, sharing its index,
with one column per embedding dimension — so it joins straight back onto the
original data.
A trained model can be saved with its preprocessing pipeline and reloaded to embed new rows the same way:
import tempfile
from pathlib import Path
import row2vec
df = row2vec.generate_synthetic_data(100)
base = Path(tempfile.mkdtemp()) / "model"
embeddings, saved = row2vec.train_and_save_model(
df, base_path=str(base), mode="pca", embedding_dim=2
)
# One .r2v file. Loading it runs no code from the file; see SECURITY.md.
model = row2vec.load_model(saved)
# The reloaded model reproduces what training returned, scaling included.
assert model.predict(df).shape == embeddings.shape
| Mode | Use it for | Key parameter |
|---|---|---|
pca | a fast linear baseline with interpretable components | embedding_dim |
unsupervised | non-linear structure, via an autoencoder | hidden_units, max_epochs |
tsne | 2-D/3-D plots that show local structure and clusters | perplexity |
umap | preserving local and global structure | n_neighbors, min_dist |
target | supervision from a label column; aggregate_by_reference=True for one vector per category | reference_column |
contrastive | supervision from pairs known to be alike or unalike | auto_pairs, margin |
Start with pca. It costs nothing to run and tells you whether the structure
you are after is linear; if it isn't, unsupervised is the next step.
AdaptiveImputer).minmax, standard, l2, tanh). The scaler is
kept with the model, so a saved model reproduces its training output.compare_modes(df, target=...) fits several modes on
the same rows and scores them on held-out rows (neighbourhood preservation
and, given a target, a downstream score), next to a no-embedding baseline.search_architecture,
auto_select_dimension).A command-line interface for batch work:
row2vec annotate --input data.csv --output embeddings.csv --mode pca --dim 5
row2vec train --input data.csv --output model.py --mode unsupervised --dim 10
row2vec predict --input new.csv --model model.py --output predictions.csv
A scikit-learn transformer and classifier (Row2VecTransformer,
Row2VecClassifier) for use inside a Pipeline, and a pandas accessor
(df.row2vec.pca(dim=2)) for quick interactive work.
py.typed), strict linting
and type-checking, and a test suite run across Python 3.11–3.13 on Linux,
macOS, and Windows. Every example in this README and in the User Guide is
executed by that suite.If you use Row2Vec in academic research, please cite:
@software{tresoldi_row2vec_2026,
author = {Tresoldi, Tiago},
title = {Row2Vec: Neural and classical embeddings for tabular data},
url = {https://github.com/tresoldi/row2vec},
version = {0.2.0},
year = {2026}
}
This library was originally developed as part of the "Cultural Evolution of Texts" project, led by Michael Dunn at the Department of Linguistics and Philology, Uppsala University.
MIT — see LICENSE.