Skip to main content

PyPI version downloads test deploy docs codecov DOI

tda-mapper

A simple and efficient Python implementation of Mapper algorithm for Topological Data Analysis

The Mapper algorithm is a well-known technique in the field of topological data analysis that allows data to be represented as a graph. Mapper is used in various fields such as machine learning, data mining, and social sciences, due to its ability to preserve topological features of the underlying space, providing a visual representation that facilitates exploration and interpretation. For an in-depth coverage of Mapper you can read the original paper.

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

Example

Here you can find an example to use to kickstart your analysis. In this toy-example we use a two-dimensional dataset of two concentric circles. The Mapper graph is a topological summary of the whole point cloud.

import numpy as np

from sklearn.datasets import make_circles
from sklearn.decomposition import PCA
from sklearn.cluster import DBSCAN

from tdamapper.core import MapperAlgorithm
from tdamapper.cover import CubicalCover
from tdamapper.plot import MapperLayoutInteractive

X, y = make_circles(                # load a labelled dataset
    n_samples=5000,
    noise=0.05,
    factor=0.3,
    random_state=42)
lens = PCA(2).fit_transform(X)

mapper_algo = MapperAlgorithm(
    cover=CubicalCover(
        n_intervals=10,
        overlap_frac=0.3),
    clustering=DBSCAN())
mapper_graph = mapper_algo.fit_transform(X, lens)

mapper_plot = MapperLayoutInteractive(
    mapper_graph,
    colors=y,                       # color according to categorical values
    cmap='jet',                     # Jet colormap, for classes
    agg=np.nanmean,                 # aggregate on nodes according to mean
    dim=2,
    iterations=60,
    seed=42,
    width=600,
    height=600)

fig_mean = mapper_plot.plot()
fig_mean.show(config={'scrollZoom': True})

mapper_plot.update(                 # reuse the plot with the same positions
    colors=y,
    cmap='viridis',                 # viridis colormap, for ranges
    agg=np.nanstd,                  # aggregate on nodes according to std
)

fig_std = mapper_plot.plot()
fig_std.show(config={'scrollZoom': True})
Dataset Mapper graph (average) Mapper graph (deviation)
Dataset Mapper graph (average) Mapper graph (standard deviation)

More examples can be found in the documentation https://tda-mapper.readthedocs.io/en/main/.

Citations

To cite tda-mapper in your work you can use the Zenodo archive https://doi.org/10.5281/zenodo.10642381.

In the archive you can find a permanent reference to the exact version you used in your work.

For example, to cite version v0.4.0 you can use:

Simi, L. (2024). tda-mapper (v0.4.0). Zenodo. https://doi.org/10.5281/zenodo.10655755

BibTeX entry:

@software{tda-mapper_v0.4.0,
  author       = {Simi, Luca},
  title        = {tda-mapper},
  month        = feb,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {v0.4.0},
  doi          = {10.5281/zenodo.10655755},
  url          = {https://doi.org/10.5281/zenodo.10655755}
}

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.5.2.tar.gz (32.5 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.5.2-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file tda-mapper-0.5.2.tar.gz.

File metadata

  • Download URL: tda-mapper-0.5.2.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for tda-mapper-0.5.2.tar.gz
Algorithm Hash digest
SHA256 72b0a61227c2d0abc788b1cfd4a8e95552bdc6627da4eae13e1fe3ef7c3f2d7c
MD5 e05ca3b3a82b92e9814ac1cb6348cf05
BLAKE2b-256 96294ca3139cb2207bf5149c3b4f224c28088eacec3644450d41570eeeab56fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tda_mapper-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for tda_mapper-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b685495e559f31fe6c1b32ed46c835fa114835e06ed2fa7f0b5dd0cf766ff551
MD5 4b6e42c48cab1053f061633d764c9c86
BLAKE2b-256 ce1c9812cbc1f4dd4846fcbd620bb1b31cbdf43e427dd8e7a8e9d5caff6c32cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page