Skip to main content

Topological Data Analysis in Python

Project description

mogutda: Topological Data Analysis in Python

CircleCI GitHub release Documentation Status Updates Python 3 pypi download stars

Introduction

mogutda contains Python codes that demonstrate the numerical calculation of algebraic topology in an application to topological data analysis (TDA). Its core code is the numerical methods concerning implicial complex, and the estimation of homology and Betti numbers.

Topological data analysis aims at studying the shapes of the data, and draw some insights from them. A lot of machine learning algorithms deal with distances, which are extremely useful, but they miss the information the data may carry from their geometry.

History

The codes in this package were developed as a demonstration of a few posts of my blog. It was not designed to be a Python package but a pedagogical collection of codes. (See: PyTDA.) However, the codes and the blog posts have been unexpectedly popular. Therefore, I modularized the code into the package mogu. (or corresponding repository: MoguNumerics) However, mogu is simply a collection of unrelated numerical routines with a lot of dependencies, but the part of TDA can be quite independent.

In order to provide other researchers and developers an independent package, which is compact (without unecessary alternative packages to load), and efficient, I decided to modularize the codes of TDA separately, and name this package mogutda.

Prerequisite

It runs under Python 3.8, 3.9, 3.10, 3.11, 3.12, and 3.13.

Simple Tutorial: Simplicial Complex

You can install by:

pip install mogutda

To establish a simplicial complex for a torus, type

import numpy as np
from mogutda import SimplicialComplex

torus_sc = [(1,2,4), (4,2,5), (2,3,5), (3,5,6), (5,6,1), (1,6,2), (6,7,2), (7,3,2),
            (1,3,4), (3,4,6), (4,6,7), (4,5,7), (5,7,1), (7,3,1)]
torus_c = SimplicialComplex(simplices=torus_sc)

To retrieve its Betti numbers, type:

print(torus_c.betti_number(0))   # print 1
print(torus_c.betti_number(1))   # print 2
print(torus_c.betti_number(2))   # print 1

Demo Codes and Blog Entries

Codes in this repository are demo codes for a few entries of my blog, Everything about Data Analytics, and the corresponding entries are:

Wolfram Demonstration

Richard Hennigan put a nice Wolfram Demonstration online explaining what the simplicial complexes are, and how homologies are defined:

News

  • 03/23/2026: mogutda 0.4.6 released.
  • 10/11/2025: mogutda 0.4.5 released.
  • 01/09/2025: mogutda 0.4.4 released.
  • 09/19/2024: mogutda 0.4.3 released.
  • 07/16/2024: mogutsa 0.4.2 released.
  • 11/23/2023: mogutda 0.4.1 released.
  • 08/18/2023: mogutda 0.4.0 released.
  • 06/20/2023: mogutda 0.3.5 released.
  • 09/09/2022: mogutda 0.3.4 released.
  • 07/15/2021: mogutda 0.3.3 released.
  • 04/10/2021: mogutda 0.3.2 released.
  • 11/28/2020: mogutda 0.3.1 released.
  • 08/16/2020: mogutda 0.3.0 released.
  • 04/28/2020: mogutda 0.2.1 released.
  • 01/16/2020: mogutda 0.2.0 released.
  • 02/20/2019: mogutda 0.1.5 released.
  • 12/31/2018: mogutda 0.1.4 released.
  • 07/18/2018: mogutda 0.1.3 released.
  • 07/02/2018: mogutda 0.1.2 released.
  • 06/13/2018: mogutda 0.1.1 released.
  • 06/11/2018: mogutda 0.1.0 released.

Other TDA Packages

It is recommended that for real application, you should use the following packages for efficiency, because my codes serve the pedagogical purpose only.

C++

Python

R

Contributions

If you want to contribute, feel free to fork the repository, and submit a pull request whenever you are ready.

If you spot any bugs or issues, go to the Issue page.

I may not approve pull request immediately if your suggested change is big. If you want to incorporate something big, please discuss with me first.

References

  • Afra J. Zomorodian. Topology for Computing (New York, NY: Cambridge University Press, 2009). [Amazon]
  • Afra J. Zomorodian. "Topological Data Analysis," Proceedings of Symposia in Applied Mathematics (2011). [link]
  • Afra Zomorodian, Gunnar Carlsson, “Computing Persistent Homology,” Discrete Comput. Geom. 33, 249-274 (2005). [pdf]
  • Gunnar Carlsson, “Topology and Data”, Bull. Amer. Math. Soc. 46, 255-308 (2009). [link]
  • Jeffrey Ray, Marcello Trovati, "A Survey of Topological Data Analysis (TDA) Methods Implemented in Python," in Advances in Intelligent Networking and Collaborative Systems, Springer (2018).
  • P. Y. Lum, G. Singh, A. Lehman, T. Ishkanov, M. Vejdemo-Johansson, M. Alagappan, J. Carlsson, G. Carlsson, “Extracting insights from the shape of complex data using topology”, Sci. Rep. 3, 1236 (2013). [link]
  • Robert Ghrist, “Barcodes: The persistent topology of data,” Bull. Amer. Math. Soc. 45, 1-15 (2008). [pdf]

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mogutda-0.4.6.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mogutda-0.4.6-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file mogutda-0.4.6.tar.gz.

File metadata

  • Download URL: mogutda-0.4.6.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mogutda-0.4.6.tar.gz
Algorithm Hash digest
SHA256 fba3d5dc7b046bb2590e6a3e453adf5424e89c01451a7e6855232b511ba05907
MD5 8abe9d6b8603a83c96d481a70d3f09dd
BLAKE2b-256 b0843178a4606b7d7cb921d296c11207eeab773f54aaa9161ed6ff406b762718

See more details on using hashes here.

File details

Details for the file mogutda-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: mogutda-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mogutda-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f215226e2856d5c64dbf2f70ed203495fa3d82eaec7636323b55b19738e6fc61
MD5 fd20e09a6c99cb111a64c60968bbabcf
BLAKE2b-256 8f8d6828fab3ec9a0765e40a68ba1c8b63d52ec7f41b323363313d5d383488cb

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