Tuesday, October 27, 2026
HomeData ScienceTopological Data Analysis – Persistent Homology, Mapper Algorithm and TDA for Machine...

Topological Data Analysis – Persistent Homology, Mapper Algorithm and TDA for Machine Learning

Table of Content

📋 KEY INSIGHTS

  • Topological Data Analysis (TDA) is a branch of applied mathematics that uses techniques from algebraic topology β€” particularly persistent homology β€” to extract shape features from data that are robust to noise, rotation, scaling, and deformation. The central insight of TDA is that the topology (connected components, loops, voids) of data clouds encodes structure that is invisible to standard distance-based or density-based methods.
  • Persistent homology is the core TDA algorithm: it builds a filtration of simplicial complexes (Vietoris-Rips or Čech complex) by gradually increasing a scale parameter Ξ΅, tracking when topological features (connected components at dimension 0, loops at dimension 1, voids at dimension 2) are born and die as Ξ΅ increases. The result is a persistence diagram β€” a scatter plot where each point (birth, death) represents one topological feature, with points far from the diagonal representing persistent, structurally significant features and points near the diagonal representing noise.
  • The Mapper algorithm is the most practically applicable TDA tool for exploratory data analysis: it builds a graph summary of high-dimensional data by covering the output of a filter function (e.g., PCA projection, density estimate) with overlapping intervals, clustering data points within each interval, and connecting clusters that share points between adjacent intervals. Mapper reveals the global shape of data β€” branching structures, loops, flares β€” that are invisible in standard 2D projections, making it a powerful complement to t-SNE and UMAP.
  • Persistence diagrams and persistence images are topological feature representations that convert the output of persistent homology into fixed-size vectors usable as input to standard ML classifiers. Persistence images bin the persistence diagram into a 2D pixel grid (weighted by persistence = death βˆ’ birth) and flatten it to a vector. These topological features capture multi-scale shape information that complements standard geometric features (mean, variance, skewness) and improves classification accuracy on 3D molecular shape, medical imaging, and material science datasets.
  • TDA is most powerful for data where shape matters: protein folding structures (the topology of a protein’s contact map encodes its folding state), material science (pore structure topology of porous materials predicts permeability), neuroscience (the topology of neural activity patterns distinguishes cognitive states), and time series (the topology of a time-delay embedding encodes periodicity and chaos). For these domains, persistent homology features consistently improve classification accuracy when added to standard feature sets.
  • The Wasserstein and bottleneck distances are metrics between persistence diagrams: the bottleneck distance d_B(D1, D2) = inf_Ξ³ sup_x ||x βˆ’ Ξ³(x)||∞ (where Ξ³ ranges over all matchings between diagram points) measures the worst-case matching cost; the p-Wasserstein distance measures the average matching cost. These metrics make persistence diagrams comparable across samples and enable kernel methods on topological features (the persistence Fisher kernel, the sliced Wasserstein kernel).

Standard machine learning methods describe data in terms of distances, densities, and linear relationships β€” how far points are from cluster centres, how correlated features are, how smoothly functions vary. These descriptions are powerful for many tasks but blind to a fundamental aspect of data structure: its shape. Two datasets can have identical means, variances, and pairwise distance distributions but differ radically in their topological structure β€” one may form a ring, another a sphere, another a branching tree. Topological Data Analysis (TDA) fills this gap by extracting shape features that are invariant to continuous deformations, robust to noise, and sensitive to geometric structures at multiple scales simultaneously. While TDA originated in pure mathematics, it has found practical applications in drug discovery (molecular shape analysis), materials science (pore structure characterisation), neuroscience (brain state classification), and medical imaging. This guide introduces persistent homology, persistence diagrams, the Mapper algorithm for exploratory data analysis, and the practical Python tools (Gudhi, Giotto-TDA, KeplerMapper) for incorporating TDA into ML pipelines.

Simplicial Complexes and the Filtration

The foundational data structure in TDA is the simplicial complex β€” a generalisation of a graph that includes higher-dimensional structures: 0-simplices are points, 1-simplices are edges, 2-simplices are filled triangles, 3-simplices are filled tetrahedra, and so on. The Vietoris-Rips complex VR(X, Ξ΅) built from a point cloud X at scale Ξ΅ includes a k-simplex (connecting k+1 points) whenever all pairwise distances between those k+1 points are at most Ξ΅. As Ξ΅ increases from 0 to ∞, VR(X, Ξ΅) grows from a set of isolated points (no edges) through increasingly connected graphs to eventually a fully connected complex. The filtration is this nested sequence of complexes: VR(X, Ρ₁) βŠ† VR(X, Ξ΅β‚‚) βŠ† … for Ρ₁ < Ξ΅β‚‚ < …. The topological features of the data β€” how many connected components exist, how many loops, how many enclosed voids β€” change as Ξ΅ increases: components merge, loops fill in, voids collapse. Persistent homology tracks these changes. The connection to our clustering guide is illuminating: the merging of connected components in the Vietoris-Rips filtration as Ξ΅ increases is exactly the single-linkage hierarchical clustering dendrogram, but persistent homology goes further by tracking higher-dimensional features (loops, voids) that clustering ignores.

Persistent homology computes, for each dimension k, the collection of k-dimensional topological features and their lifetimes (birth Ξ΅, death Ξ΅). The persistence of a feature is death βˆ’ birth: highly persistent features (far from the diagonal in the persistence diagram) are structurally significant; low-persistence features (near the diagonal) are noise. For a point cloud sampled from a circle, persistent homology in dimension 1 produces one highly persistent loop (the circle) and many low-persistence noise loops. For a point cloud sampled from a torus, it produces two highly persistent loops (the two fundamental cycles of the torus). This scale-free, multi-dimensional characterisation of shape is what makes TDA uniquely powerful for shape-sensitive applications.

TDA ConceptDescriptionPractical Use
Persistence diagramScatter plot of (birth, death) pairs per featureShape fingerprint; ML feature input
Persistence imageBinned persistence diagram (fixed-size vector)Input to SVM, RF, CNN classifiers
Betti numbersCount of k-dim features at a given scaleSummary statistics of topology
Mapper graphGraph summary of data shape via filter + clusteringExploratory analysis; cluster structure
Wasserstein distanceOptimal transport distance between diagramsComparing topological features across samples
Persistence landscapeFunctional summary of persistence diagramMean/variance over diagram collections

The Mapper Algorithm for Exploratory Data Analysis

graphical user interface
Photo by Deng Xiang on Unsplash

The Mapper algorithm (Singh, MΓ©moli, Carlsson, 2007) is the TDA tool most directly applicable to exploratory data analysis on tabular and high-dimensional data. The algorithm: (1) Apply a filter function f: X β†’ ℝ (or ℝ²) that maps data points to a low-dimensional space β€” common choices are a PCA projection, a density estimate, or a graph-based measure like eccentricity; (2) Cover the filter space with overlapping intervals (or patches); (3) Within each interval, cluster the preimage f⁻¹(interval) using any clustering algorithm (k-means, DBSCAN from our clustering guide); (4) Build a graph where each cluster is a node and two nodes are connected if their corresponding data subsets share at least one point. The resulting Mapper graph summarises the global shape of the data in a way that t-SNE and UMAP cannot: Mapper faithfully represents branching structures (e.g., a dataset where cancer subtypes form branches from a central trunk), loops (circular structures in gene expression data), and flares (outlier-attracting extremities). A canonical use case from cancer genomics: Mapper applied to gene expression data from 5000 breast cancer tumours reveals a branching structure where a specific branch (with a loop) corresponds to tumours with a particular genomic alteration β€” a discovery that was invisible in standard PCA/t-SNE projections.

For practical use, the KeplerMapper Python library implements Mapper with an interactive HTML visualisation, and giotto-tda provides a scikit-learn-compatible API for both Mapper and persistent homology. The connection to our dimensionality reduction guide is direct: Mapper uses PCA, UMAP, or t-SNE as the filter function, and the Mapper graph provides a topological complement to those 2D projections β€” showing global shape structure that is distorted or lost in any single 2D projection. For feature engineering, persistence images and Betti number curves from persistent homology can be added as supplementary features to any tabular ML pipeline, typically improving performance on shape-sensitive tasks (molecular property prediction, medical imaging classification) by 2-10% AUC over baselines without TDA features. The connection to our feature engineering guide is direct: TDA features are an additional feature engineering technique for spatial and shape-rich data types.

Applications in Drug Discovery, Neuroscience and Time Series

In drug discovery, persistent homology applied to 3D molecular point clouds (atomic coordinates) captures the topological structure of molecular binding pockets and surface cavities β€” features critical for protein-ligand binding affinity prediction. Persistence images derived from molecular surface triangulations have improved the accuracy of binding affinity prediction models, complementing standard 3D graph neural network features from our GNN guide. In neuroscience, the topology of neural activity patterns (point clouds in neural state space, one point per brain state) distinguishes cognitive states, sleep stages, and disease conditions: the number and persistence of loops in the neural activity manifold encodes task engagement and memory consolidation in ways that standard clustering or dimensionality reduction misses. For time series, the time-delay embedding (plotting (x_t, x_{t+Ο„})) of a periodic time series forms a loop whose persistent H₁ feature has high persistence; a chaotic time series produces a diffuse cloud with low persistence β€” enabling TDA-based classification of time series by their dynamical regime, complementing the pattern-based approach of our Time Series Classification guide.

✦ SUMMARIZE THIS ARTICLE WITH AI

Dimensionality reduction (PCA, UMAP, t-SNE) used as Mapper filter functions is in our Dimensionality Reduction guide. Clustering algorithms used in the Mapper step are in our Clustering guide. Feature engineering for incorporating TDA features into ML pipelines is in our Feature Engineering guide. Graph Neural Networks for molecular shape and graph-structured TDA extensions are in our Graph Neural Networks guide. Time series classification that complements TDA on time series is in our Time Series Classification guide.

Leave feedback about this

  • Rating

Durgesh Kekare
Durgesh Kekarehttps://www.dataexpertise.in
Durgesh Kekare is a data science educator and founder of DataExpertise.in. With expertise in Python, machine learning, and analytics, he helps 10,000+ learners break into data careers.

Latest Posts

List of Categories