Skip to content

SG-t-SNE-Pi logo PySGtSNEpi

SG-t-SNE-Pi embedding demo

PyPI version Python 3.10–3.13 License: MIT CI Docs

Embed sparse graphs into 2D/3D — pure Python, pip-installable, sklearn-compatible.

PySGtSNEpi is a pure Python port of the SG-t-SNE-Pi algorithm, translated from the original C++ and Julia implementations. Unlike standard t-SNE, SG-t-SNE-Pi works on any sparse stochastic graph, not just kNN graphs derived from point clouds. No C/C++ compiler needed — pip install and go.

Features

  • 1D / 2D / 3D embedding of sparse stochastic graphs
  • Arbitrary sparse graph input — not limited to kNN graphs
  • Point cloud input with automatic kNN graph construction via PyNNDescent
  • Lambda rescaling to equalize effective node degrees
  • Scikit-learn compatible API (fit / transform / fit_transform)
  • Pure Python — runs on Windows, macOS (including Apple Silicon), and Linux
  • Numba JIT compiled hot loops for near-native speed
  • FFT-accelerated repulsive force computation

Quick Start

pip install pysgtsnepi

Scikit-learn API (point cloud)

from pysgtsnepi import SGtSNEpi

model = SGtSNEpi(d=2, lambda_=10)
Y = model.fit_transform(X)   # X is (n_samples, n_features)

Functional API (sparse graph)

from scipy.io import mmread
from pysgtsnepi import sgtsnepi

P = mmread("graph.mtx")       # sparse stochastic graph
Y = sgtsnepi(P, d=3, lambda_=10)

Roadmap

  • [x] Lambda equalization
  • [x] kNN graph construction (via PyNNDescent)
  • [x] Core SG-t-SNE-Pi embedding (attractive + repulsive forces)
  • [x] FFT-accelerated repulsive forces
  • [x] Numba JIT for interpolation and gradient kernels
  • [x] 1D / 3D embedding support
  • [x] SGtSNEpi sklearn estimator class
  • [x] sgtsnepi() functional API

Citation

If you use this package in your research, please cite:

@article{pitsianis2019joss,
  title     = {{SG-t-SNE-$\Pi$}: Swift Neighbor Embedding of Sparse Stochastic Graphs},
  author    = {Pitsianis, Nikos and Floros, Dimitris and Iliopoulos, Alexandros-Stavros and Sun, Xiaobai},
  journal   = {Journal of Open Source Software},
  volume    = {4},
  number    = {39},
  pages     = {1577},
  year      = {2019},
  doi       = {10.21105/joss.01577}
}

@inproceedings{pitsianis2019hpec,
  title     = {Spaceland Embedding of Sparse Stochastic Graphs},
  author    = {Pitsianis, Nikos and Iliopoulos, Alexandros-Stavros and Floros, Dimitris and Sun, Xiaobai},
  booktitle = {IEEE High Performance Extreme Computing Conference},
  year      = {2019},
  doi       = {10.1109/HPEC.2019.8916505}
}

License

MIT — see LICENSE.