https://github.com/luisscoccola/shapediscover
Cover learning with geometric optimization
https://github.com/luisscoccola/shapediscover
dimensionality-reduction manifold-learning representation-learning topological-data-analysis
Last synced: 8 months ago
JSON representation
Cover learning with geometric optimization
- Host: GitHub
- URL: https://github.com/luisscoccola/shapediscover
- Owner: LuisScoccola
- License: bsd-3-clause
- Created: 2025-02-26T16:37:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-21T10:06:06.000Z (9 months ago)
- Last Synced: 2025-09-21T12:07:31.885Z (9 months ago)
- Topics: dimensionality-reduction, manifold-learning, representation-learning, topological-data-analysis
- Language: Python
- Homepage:
- Size: 13.8 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ShapeDiscover
Learn covers of data with geometric optimization,
for topological inference and visualization.
See [[SLH, ICML25]](#1) for background on _cover learning_ and _topological inference_.
> [!Note]
> Alpha version. User-facing interface is subject to breaking changes.
## Installation
Basic installation:
```pip install .```
Some examples require extra libraries that can be installed with:
```pip install ".[extras]"```
## Examples
These are two small examples that use `ShapeDiscoverLite`, which is the currently recommended interface.
See notebooks in the `examples` directory for more examples.
### Topological inference
Recovering the topology of a two-dimensional sphere.
We choose a cover with 25 elements for illustration purposes, but ShapeDiscover recovers the correct topology with as few as 5 cover elements.
```python
from shapediscover import ShapeDiscoverLite, FuzzyCoverPersistence
import gudhi
from synthetic_data import sphere
X = sphere(2000, 2)
coverer = ShapeDiscoverLite(25)
fuzzy_cover = coverer.fit_transform(X)
persistence_barcode = FuzzyCoverPersistence(max_dimension=2, log_rescaling=True).fit_transform(fuzzy_cover)
gudhi.plot_persistence_barcode(persistence_barcode)
plt.show()
```

### Visualization
We visualize the MNIST handwritten digits dataset.
```python
from shapediscover import plot_nerve
import torchvision
mnist_dataset = torchvision.datasets.MNIST(root="./datasets", download=True)
X = np.array([np.array(image_label[0]).flatten() for image_label in mnist_dataset])
y = np.array([image_label[1] for image_label in mnist_dataset])
coverer = ShapeDiscoverLite(10,regularization=40)
fuzzy_cover = coverer.fit_transform(X)
plot_nerve(fuzzy_cover, threshold=0.8, interactive=True, max_vertex_size=0.8, labels=y)
```

The output of ShapeDiscover on the left, and UMAP's two-dimensional projection on the right, for comparison.
## Authors
[Luis Scoccola](https://luisscoccola.com/) and [Uzu Lim](https://sites.google.com/view/uzulim/main).
## References
[SLH, ICML25]
*Cover learning for large-scale topology representation*. Luis Scoccola, Uzu Lim, Heather A. Harrington. International Conference on Machine Learning (ICML 2025)
## License
This software is published under the 3-clause BSD license.