@@ -23,7 +23,7 @@ Further details in the
2323and in the
2424[ paper] ( https://openreview.net/pdf?id=lTX4bYREAZ ) .
2525
26- ### Main Features
26+ ## Main Features
2727
2828- ** Fast Mapper graph construction** : Accelerates computations with efficient spatial search, enabling analysis of large, high-dimensional datasets.
2929
@@ -33,7 +33,7 @@ and in the
3333
3434- ** Interactive exploration** : Explore data interactively through a user-friendly app.
3535
36- ### Background
36+ ## Background
3737
3838The Mapper algorithm transforms complex datasets into graph representations
3939that highlight clusters, transitions, and topological features. These insights
@@ -47,7 +47,7 @@ its mathematical foundations and applications, read the
4747| ![ Step 1] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/mapper_1.png ) | ![ Step 2] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/mapper_2.png ) | ![ Step 3] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/mapper_3.png ) | ![ Step 2] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/mapper_4.png ) |
4848| Choose lens | Cover image | Run clustering | Build graph |
4949
50- ### Citations
50+ ## Citations
5151
5252If you use ** tda-mapper** in your work, please consider citing both the
5353[ library] ( https://doi.org/10.5281/zenodo.10642381 ) , archived in a permanent
@@ -71,41 +71,53 @@ pip install tda-mapper
7171
7272### How to Use
7373
74- Here's a minimal example using the ** circles dataset** from ` scikit-learn ` to
75- demonstrate how to use ** tda-mapper** :
74+ Here's a minimal example using the ** circles dataset** from ` scikit-learn ` to demonstrate how to use ** tda-mapper** .
75+ We start by generating the data and visualizing it.
76+ The dataset consists of two concentric circles.
77+ The goal is to compute a Mapper graph that summarizes this structure while preserving topological features.
78+ We proceed as follows:
7679
77- ``` python
78- import numpy as np
7980
81+ ``` python
82+ import matplotlib.pyplot as plt
8083from sklearn.datasets import make_circles
84+
85+ import numpy as np
8186from sklearn.decomposition import PCA
8287from sklearn.cluster import DBSCAN
8388
8489from tdamapper.learn import MapperAlgorithm
8590from tdamapper.cover import CubicalCover
8691from tdamapper.plot import MapperPlot
8792
88- # load a labelled dataset
93+ # Generate toy dataset
8994X, labels = make_circles(n_samples = 5000 , noise = 0.05 , factor = 0.3 , random_state = 42 )
95+ plt.scatter(X[:,0 ], X[:,1 ], c = labels, cmap = ' jet' , s = 0.25 )
96+ plt.show()
97+
98+ # Apply PCA as lens
9099y = PCA(2 , random_state = 42 ).fit_transform(X)
91100
101+ # Mapper pipeline
92102cover = CubicalCover(n_intervals = 10 , overlap_frac = 0.3 )
93103clust = DBSCAN()
94104graph = MapperAlgorithm(cover, clust).fit_transform(X, y)
95105
96- # color according to labels
106+ # Visualize the Mapper graph
97107fig = MapperPlot(graph, dim = 2 , seed = 42 , iterations = 60 ).plot_plotly(colors = labels)
98108fig.show(config = {' scrollZoom' : True })
99109```
100110
101111| Original Dataset | Mapper Graph |
102112| ---------------- | ------------ |
103- | ![ Original Dataset] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/circles_dataset.png ) | ![ Mapper Graph] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/circles_mean.png ) |
113+ | ![ Original Dataset] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/circles_dataset_v2.png ) | ![ Mapper Graph] ( https://github.com/lucasimi/tda-mapper-python/raw/main/resources/circles_mean_v2.png ) |
114+
115+ 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.
104116
105117More examples can be found in the
106118[ documentation] ( https://tda-mapper.readthedocs.io/en/main/examples.html ) .
107119
108- ### Interactive App
120+ ## Interactive App
109121
110122Use our Streamlit app to visualize and explore your data without writing code.
111123You can run a live demo directly on
0 commit comments