Skip to main content

tda-mapper

PyPI version downloads test deploy docs codecov DOI

This Python package provides a simple and efficient implementation of Mapper algorithm.

About Mapper

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 a lens Cover the image of the lens Perform clustering on the pullback cover Build the Mapper graph

Usage

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 MapperPlot

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 = MapperPlot(
    X, 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)
fig_mean = mapper_plot.plot(
    width=600,
    height=600)
fig_mean.show(config={'scrollZoom': True})

fig_std = mapper_plot.with_colors(  # reuse the plot with the same positions
    colors=y,
    cmap='viridis',                 # viridis colormap, for ranges
    agg=np.nanstd,                  # aggregate on nodes according to std
).plot(
    width=600,
    height=600)
fig_std.show(config={'scrollZoom': True})
Dataset Mapper graph (average) Mapper graph (deviation)
Dataset Mapper graph (average) Mapper graph (standard deviation)

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.4.0.tar.gz (27.7 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.4.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tda-mapper-0.4.0.tar.gz
  • Upload date:
  • Size: 27.7 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.4.0.tar.gz
Algorithm Hash digest
SHA256 cf99107e12b7aa61dd133d7e33e6045f4f4fb56cb0883cb13535b7561684b9b6
MD5 a4f8e6f95801cdcaea7d3a03534e6cd7
BLAKE2b-256 a03225b4fbd2732e01cb155becc9fc0f622abcc43cf65c51af60e135bbbd1362

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tda_mapper-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5b11fbcc080587440e328961761566c65f2a2216917057684cdab2b962721af
MD5 309bdf79b30db237a3949adac0126b13
BLAKE2b-256 56a59e9118c00ab7bb6783b77bb0e467dfaf324689f2b5be58de1b170675090e

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 Pingdom Monitoring Sentry Error logging StatusPage Status page