Manify is a Python library for non-Euclidean representation learning.
It is built on top of geoopt
and follows scikit-learn
API conventions.
The library supports a variety of workflows involving (products of) Riemannian manifolds, including:
- All basic manifold operations (e.g. exponential map, logarithmic map, parallel transport, and distance computations)
- Sampling Gaussian distributions and Gaussian mixtures
- Learning embeddings of data on product manifolds, using features and/or distances
- Training machine learning models on manifold-valued embeddings, including decision trees, random forests, SVMs, perceptrons, and neural networks.
- Clustering manifold-valued data using Riemannian fuzzy K-Means
There are two ways to install manify
:
-
From PyPI:
pip install manify
-
From GitHub (recommended due to active development of the repo):
pip install git+https://github.com/pchlenski/manify
import manify
from manify.utils.dataloaders import load_hf
from sklearn.model_selection import train_test_split
# Load Polblogs graph from HuggingFace
features, dists, adj, labels = load_hf("polblogs")
# Create an S^4 x H^4 product manifold
pm = manify.ProductManifold(signature=[(1.0, 4), (-1.0, 4)])
# Learn embeddings (Gu et al (2018) method)
embedder = manify.CoordinateLearning(pm=pm)
X_embedded = embedder.fit_transform(X=None, D=dists, burn_in_iterations=200, training_iterations=800)
# Train and evaluate classifier (Chlenski et al (2025) method)
X_train, X_test, y_train, y_test = train_test_split(X_embedded, labels)
model = manify.ProductSpaceDT(pm=pm, max_depth=3, task="classification")
model.fit(X_train, y_train)
print(model.score(X_test, y_test))
The official tutorial for Manify can be found in tutorial.ipynb
. This Jupyter
notebook contains a comprehensive overview of all of the library's core features.
Manifold Operations
manify.manifolds
- Tools for generating Riemannian manifolds and product manifolds
Curvature Estimation
manify.curvature_estimation.delta_hyperbolicity
- Compute delta-hyperbolicity of a metric spacemanify.curvature_estimation.greedy_method
- Greedy selection of near-optimal signaturesmanify.curvature_estimation.sectional_curvature
- Sectional curvature estimation using Toponogov's theorem
Embedders
manify.embedders.coordinate_learning
- Coordinate learning and optimizationmanify.embedders.siamese
- Siamese network embeddermanify.embedders.vae
- Product space variational autoencoder
Predictors
manify.predictors.nn
- Neural network layersmanify.predictors.decision_tree
- Decision tree and random forest predictorsmanify.predictors.kappa_gcn
- Kappa GCNmanify.predictors.perceptron
- Product space perceptronmanify.predictors.svm
- Product space SVM
Clustering
manify.clustering.fuzzy_kmeans
- Riemannian fuzzy K-Means for clustering
Optimizers
manify.optimizers.radan
- Riemannian version of Adan optimizer
Utilities
manify.utils.benchmarks
- Tools for benchmarkingmanify.utils.dataloaders
- Loading datasetsmanify.utils.link_prediction
- Preprocessing graphs with link predictionmanify.utils.visualization
- Tools for visualization
This repo has a number of archival branches that contain code from previous versions of the library when it was under active development. These branches are not maintained and are provided for reference only:
- Dataset-Generation. This branch contains code used to
generate the datasets found in
manify.utils.dataloaders
. - notebook-archive. This branch contains dozens of Jupyter notebooks and datasets that were used to develop the library and carry out various benchmarks for the Mixed Curvature Decision Trees and Random Forests paper.
Please read our contributing guide for details on how to contribute to the project.
If you use our work, please cite the Manify
paper:
@misc{chlenski2025manifypythonlibrarylearning,
title={Manify: A Python Library for Learning Non-Euclidean Representations},
author={Philippe Chlenski and Kaizhu Du and Dylan Satow and Itsik Pe'er},
year={2025},
eprint={2503.09576},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2503.09576},
}
Additionally, if you use one of the methods implemented in manify
, please cite the original papers:
CoordinateLearning
: Gu et al. "Learning Mixed-Curvature Representations in Product Spaces." ICLR 2019. https://openreview.net/forum?id=HJxeWnCcF7ProductSpaceVAE
: Skopek et al. "Mixed-Curvature Variational Autoencoders." ICLR 2020. https://openreview.net/forum?id=S1g6xeSKDSSiameseNetwork
: Based on Siamese networks: Chopra et al. "Learning a Similarity Metric Discriminatively, with Application to Face Verification." CVPR 2005. https://ieeexplore.ieee.org/document/1467314ProductSpaceDT
andProductSpaceRF
: Chlenski et al. "Mixed Curvature Decision Trees and Random Forests." ICML 2025. https://arxiv.org/abs/2410.13879KappaGCN
: Bachmann et al. "Constant Curvature Graph Convolutional Networks." ICML 2020. https://proceedings.mlr.press/v119/bachmann20a.htmlProductSpacePerceptron
andProductSpaceSVM
: Tabaghi et al. "Linear Classifiers in Product Space Forms." ArXiv 2021. https://arxiv.org/abs/2102.10204RiemannianFuzzyKMeans
andRiemannianAdan
: Yuan et al. "Riemannian Fuzzy K-Means." OpenReview 2025. https://openreview.net/forum?id=9VmOgMN4Ie- Delta-hyperbolicity computation: Based on Gromov's δ-hyperbolicity metric for tree-likeness of metric spaces. Gromov, M. "Hyperbolic Groups." Essays in Group Theory, 1987. https://link.springer.com/chapter/10.1007/978-1-4613-9586-7_3
- Sectional curvature estimation: Gu et al. "Learning Mixed-Curvature Representations in Product Spaces." ICLR 2019. https://openreview.net/forum?id=HJxeWnCcF7
- Greedy signature selection: Tabaghi et al. "Linear Classifiers in Product Space Forms." ArXiv 2021. https://arxiv.org/abs/2102.10204