Skip to main content

Logo

PyPI version downloads codecov test publish docs DOI

tda-mapper

tda-mapper is a Python library built around the Mapper algorithm, a core technique in Topological Data Analysis (TDA) for extracting topological structure from complex data. Designed for computational efficiency and scalability, it leverages optimized spatial search methods to support high-dimensional datasets. The library is well-suited for integration into machine learning pipelines, unsupervised learning tasks, and exploratory data analysis.

Further details in the documentation and in the paper.

Core Features

  • Efficient construction

    Leverages optimized spatial search techniques and parallelization to accelerate the construction of Mapper graphs, supporting the analysis of high-dimensional datasets.

  • Scikit-learn integration

    Provides custom estimators that are fully compatible with scikit-learn's API, enabling seamless integration into scikit-learn pipelines for tasks such as dimensionality reduction, clustering, and feature extraction.

  • Flexible visualization

    Multiple visualization backends supported (Plotly, Matplotlib, PyVis) for generating high-quality Mapper graph representations with adjustable layouts and styling.

  • Interactive app

    Provides an interactive web-based interface (via Streamlit) for dynamic exploration of Mapper graph structures, offering real-time adjustments to parameters and visualizations.

Background

The Mapper algorithm extracts topological features from complex datasets, representing them as graphs that highlight clusters, transitions, and key structural patterns. These insights reveal hidden data relationships and are applicable across diverse fields, including social sciences, biology, and machine learning. For an in-depth overview of Mapper, including its mathematical foundations and practical applications, read the original paper.

Step 1 Step 2 Step 3 Step 4
Step 1 Step 2 Step 3 Step 2
Choose lens Cover image Run clustering Build graph

Citations

If you use tda-mapper in your work, please consider citing both the library, archived in a permanent Zenodo record, and the paper, which provides a broader methodological overview. We recommend citing the specific version of the library used in your research, along with the paper. For citation examples, please refer to the documentation.

Quick Start

Installation

To install the latest version uploaded on PyPI

pip install tda-mapper

How to Use

Here's a minimal example using the circles dataset from scikit-learn to demonstrate how to use tda-mapper. This example demonstrates how to apply the Mapper algorithm on a synthetic dataset (concentric circles). The goal is to extract a topological graph representation using PCA as a lens and DBSCAN for clustering. We proceed as follows:

import matplotlib.pyplot as plt
from sklearn.datasets import make_circles

import numpy as np
from sklearn.decomposition import PCA
from sklearn.cluster import DBSCAN

from tdamapper.learn import MapperAlgorithm
from tdamapper.cover import CubicalCover
from tdamapper.plot import MapperPlot

# Generate toy dataset
X, labels = make_circles(n_samples=5000, noise=0.05, factor=0.3, random_state=42)
plt.figure(figsize=(5, 5))
plt.scatter(X[:,0], X[:,1], c=labels, s=0.25, cmap="jet")
plt.axis("off")
plt.show()

# Apply PCA as lens
y = PCA(2, random_state=42).fit_transform(X)

# Mapper pipeline
cover = CubicalCover(n_intervals=10, overlap_frac=0.3)
clust = DBSCAN()
graph = MapperAlgorithm(cover, clust).fit_transform(X, y)

# Visualize the Mapper graph
fig = MapperPlot(graph, dim=2, seed=42, iterations=60).plot_plotly(colors=labels)
fig.show(config={"scrollZoom": True})
Original Dataset Mapper Graph
Original Dataset Mapper Graph

Left: the original dataset consisting of two concentric circles with noise, colored by class label. Right: the resulting Mapper graph, built from the PCA projection and clustered using DBSCAN. The two concentric circles are well identified by the connected components in the Mapper graph.

More examples can be found in the documentation.

Interactive App

Use our Streamlit app to visualize and explore your data without writing code. You can run a live demo directly on Streamlit Cloud, or locally on your machine. The first time you run the app locally, you may need to install the required dependencies from the requirements.txt file by running

pip install -r app/requirements.txt

then run the app locally with

streamlit run app/streamlit_app.py

tda-mapper-app

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tda_mapper-0.11.0.tar.gz (49.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tda_mapper-0.11.0-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

File details

Details for the file tda_mapper-0.11.0.tar.gz.

File metadata

  • Download URL: tda_mapper-0.11.0.tar.gz
  • Upload date:
  • Size: 49.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tda_mapper-0.11.0.tar.gz
Algorithm Hash digest
SHA256 9f372bee096836dabfa0b67acfea01b666ae086ce7fe08fe8737e0be25a0e651
MD5 d6bfa86e78d93254e5ac7735eb4704ab
BLAKE2b-256 f65ebe5d1c5131de67f13f0dcee8056200ad6419a342e17f96a0ac038f133de3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tda_mapper-0.11.0.tar.gz:

Publisher: publish-pypi.yml on lucasimi/tda-mapper-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tda_mapper-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: tda_mapper-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 44.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tda_mapper-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c0327c85f9b82a7b22efc7d3f347867349ee493a3c985c2714aca468e2e181e
MD5 f3cf2dc9e10af80c83fca12fbb88f61f
BLAKE2b-256 e6dc2e7e8e4d17cd10e21dbd3a40bed82096ab2e290c7d20b56806b91e044c47

See more details on using hashes here.

Provenance

The following attestation bundles were made for tda_mapper-0.11.0-py3-none-any.whl:

Publisher: publish-pypi.yml on lucasimi/tda-mapper-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.12.0

2 files

0.11.2

2 files

0.11.1

2 files

This release

0.11.0 This release

2 files

0.10.0

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.3

2 files

0.7.1

67 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page