Skip to content

Commit 3ac3a9b

Browse files
authored
Merge pull request #207 from lucasimi/develop
Develop
2 parents eb27af8 + 014b708 commit 3ac3a9b

21 files changed

+749
-1057
lines changed

.readthedocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ build:
1414
# nodejs: "19"
1515
# rust: "1.64"
1616
# golang: "1.19"
17+
apt_packages:
18+
- pandoc
19+
1720

1821
# Build documentation in the "docs/" directory with Sphinx
1922
sphinx:

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Further details in the
2323
and 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

3838
The Mapper algorithm transforms complex datasets into graph representations
3939
that 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

5252
If 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
8083
from sklearn.datasets import make_circles
84+
85+
import numpy as np
8186
from sklearn.decomposition import PCA
8287
from sklearn.cluster import DBSCAN
8388

8489
from tdamapper.learn import MapperAlgorithm
8590
from tdamapper.cover import CubicalCover
8691
from tdamapper.plot import MapperPlot
8792

88-
# load a labelled dataset
93+
# Generate toy dataset
8994
X, 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
9099
y = PCA(2, random_state=42).fit_transform(X)
91100

101+
# Mapper pipeline
92102
cover = CubicalCover(n_intervals=10, overlap_frac=0.3)
93103
clust = DBSCAN()
94104
graph = MapperAlgorithm(cover, clust).fit_transform(X, y)
95105

96-
# color according to labels
106+
# Visualize the Mapper graph
97107
fig = MapperPlot(graph, dim=2, seed=42, iterations=60).plot_plotly(colors=labels)
98108
fig.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

105117
More 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

110122
Use our Streamlit app to visualize and explore your data without writing code.
111123
You can run a live demo directly on

0 commit comments

Comments
 (0)