Differentiable Mapper for Topological Optimization of Data Representation

Ziyad Oulhaj 1 Mathieu Carrière 2 Bertrand Michel 1

Abstract

gebraic topology) has also proved beneficial for highlighting subpopulations of interest, which are usually detected
as peculiar topological structures of significant sizes, andidentifying the key features that best explain such subpopulations against the rest of the Mapper graph. This generalpipeline has become a key component in, e.g., biologicalinference in single-cell data sets, where differentiating stem
cells can usually be recovered from branching patterns in
the corresponding Mapper graphs [8].

Unsupervised data representation and visualization using tools from topology is an active andgrowing field of Topological Data Analysis (TDA)
and data science. Its most prominent line of work
is based on the so-called Mapper graph, which
is a combinatorial graph whose topological structures (connected components, branches, loops)
are in correspondence with those of the data itself.
While highly generic and applicable, its use has
been hampered so far by the manual tuning of
its many parameters—among these, a crucial one
is the so-called filter: it is a continuous function
whose variations on the data set are the main ingredient for both building the Mapper representation
and assessing the presence and sizes of its topological structures. However, there is currently no
method for tuning the filter itself. In this work, webuild on a recently proposed optimization framework incorporating topology to provide the first
filter optimization scheme for Mapper graphs. In
order to achieve this, we propose a relaxed andmore general version of the Mapper graph, whose
convergence properties are investigated.

Contributions. Our contribution is three-fold:• We introduce Soft Mapper: a generalization of the combinatorial Mapper graph in the form of a probability
distribution on Mapper graphs,• We propose a filter optimization framework adapted
to a smooth Soft Mapper distribution with provableconvergence guarantees,• We implement and showcase the efficiency of Mapper
filter optimization through Soft Mapper on various data
sets, with public, open-source code in TensorFlow.

2. Background on Reeb and Mapper graphs
Reeb graphs. Mapper graphs can be understood as numerical approximations of Reeb graphs, that we now define.
Let X be a topological space and let f : X → R be acontinuous function called filter function. Let ∼f be theequivalence relation between two elements x and y in X
defined by: x ∼f y if and only if x and y are in the sameconnected component of f −1 (z) for some z in f (X). The
Reeb graph Rf (X) of X is then simply defined as the quotient space X/ ∼f .

1. Introduction
Mapper graphs and TDA. The Mapper graph introducedin [1] is an essential tool of Topological Data Analysis(TDA), and has been used many times for visualization purposes on different types of data, including, but not limited
to, single-cell sequencing [2], [3], neural network architectures [4], [5], or 3D meshes [6], [7]. Moreover, its ability
to precisely encode (within the graph) the presence andsizes of geometric and topological structures in the data
in a mathematically founded way (through the use of al*

Mapper graphs. The Mapper was introduced in [1]as a discrete and computable version of the Reeb graph
Rf (X ). Assume that we are given a point cloud Xn ={X1 , . . . , Xn } ⊆ X with known pairwise dissimilarities, aswell as a filter function f computed on each point of Xn .
The Mapper graph can then be computed with the following
generic version of the Mapper algorithm:

1

Equal contribution Nantes Université, École Centrale Nantes,
Laboratoire de Mathématiques Jean Leray, CNRS UMR 6629,
Nantes, France 2 DataShape, Centre Inria d’Université Côte d’Azur,
Sophia Antipolis, France. Correspondence to: Ziyad Oulhaj<ziyad.oulhaj@ec-nantes.fr>.
Published at the 2 nd Differentiable Almost Everything Workshop
at the 41 st International Conference on Machine Learning, Vienna, Austria. July 2024. Copyright 2024 by the author(s).

1. Cover the range of values Yn = f (Xn ) with a set of1

Differentiable Mapper

consecutive intervals I1 , . . . , Ir that overlap, i.e., one
has Ii ∩ Ii+1 ̸= ∅ for all 1 ≤ i ≤ r − 1.

3.2. Cover assignment scheme and Soft Mapper
Now, we define stochastic schemes for generating latent
cover assignments, that we call cover assignment schemes.
Definition 3.1. A cover assignment scheme is a double
indexed sequence of random variables

2. Apply a clustering algorithm to each pre-imagef −1 (Ij ), j ∈ {1, ..., r}. This defines a pullback coverC = {C1,1 , . . . , C1,k1 , . . . , Cr,1 , . . . , Cr,kr } of Xn .

A = (Ai,j )1≤i≤n

3. The Mapper graph is defined as the nerve of C. Eachnode vj,k of the Mapper graph corresponds to an element Cj,k of C, and two nodes vj,k and vj ′ ,k′ areconnected by an edge if and only if Cj,k ∩ Cj ′ ,k′ ̸= ∅.

1≤j≤rsuch that each Ai,j is a Bernoulli random variable conditionally to Xn . Let pi,j (Xn ) be the parameter of the Bernoulli
distribution of (Ai,j |Xn ), which is thus a function of thepoint cloud Xn .
Definition 3.2. Let A be a cover assignment scheme. The
Soft Mapper of A is defined as the associated distribution ofMapper complexes, which corresponds to the push forward
measure of the distribution of A by the map MapComp.

3. Soft Mapper construction
In this section, we introduce our new construction Soft Mapper, which generalizes Mapper graphs and can be used for
non-convex optimization. In order to do so, we first provide
a general formalization of the Mapper construction that does
not require overlapping intervals and filter functions. Then,
we use this formalization to define Soft Mapper, which essentially consists in a distribution on regular Mapper graphs.

4. Smooth relaxation of the standard coverassignment scheme
Given some δ > 0, we can now define a cover assignment
scheme Aδ that approximates the degenerate cover assignment scheme A∗ arising from the standard Mapper graph.
Specifically, using the same notations as before, and denoting each element of the cover with Ij = [aj , bj ], consider,for each j ∈ {1, ..., r}, the function qj : X −→ [0, 1] defined with:
if f (x) ∈ [aj , bj ]1,exp(1 − 1/(1 − ( aj −f (x) )2 )), if f (x) ∈ (a − δ, a ]
j
j
δ
x 7→
j 2
exp(1 − 1/(1 − ( f (x)−b
)
)),
if
f
(x)
∈
[b
,
b
+
δ)
j
j

δ


0,
otherwise

3.1. Mapper graphs built on latent cover assignments
Let Xn = {x1 , ..., xn } be a point cloud lying in a metricspace (X, d) and let r ∈ N⋆ . For instance, Xn can beobtained from sampling X n according to some distributionµ. Then, let Clus be a clustering algorithm on (X, d), thatis assumed to be fixed in the following of this work.
Latent cover assignments. Any binary matrix e ∈n×r
is then called an r-latent cover assignment of Xn ,{0, 1}
where ei,j = 1 must be understood as point xi belonging to
the j-th element of a latent cover of the data. For instance,in the standard version of Mapper presented in Section 2,
the latent cover is obtained from a family of pre-images ofintervals that cover the range of the filter function.

Now, define Aδ = (Aδ,i,j )1≤i≤n to be the random vari1≤j≤rable in {0, 1}n×r such that for every (i, j) ∈ {1, ..., n} ×
{1, ..., r}:Aδ,i,j | Xn ∼ B(qj (xi )),The procedure to compute a Mapper graph given an r-latentn×r
cover assignment e ∈ {0, 1}
is straightforward: simply−1
replace f (Ij ) by {xi : ei,j = 1} in the generic Mapper
algorithm in Section 2, then derive the pullback cover using the clustering algorithm Clus, and finally compute theMapper graph as the nerve of the pullback cover.

with the Aδ,i,j ’s being jointly independent conditionallyto Xn . As for the standard cover, the Bernoulli parameter
pi,j = qj (xi ) depends on its associated point xi and also on
the chosen filter f .
Moreover, notice that for every xi ∈ Xn and j ∈ {1, ..., r}:Mapper function. Let K be the set of simplicial complexes of dimension less or equal to 1 (i.e., graphs) and suchthat their sets of vertices (i.e., their 0−skeletons) are subsetsof the power set P(Xn ). We define the Mapper complex
generating function as:
MapComp : {0, 1}

n×r

qj (xi ) −−−→
δ→0

(

1,
0,

if f (xi ) ∈ Ij
otherwise,Land this shows that Aδ −−−→ A∗ .
δ→0

−→ K,

5. Topological risk of Soft Mappers

where MapComp takes a latent cover assignment as input
and creates the corresponding Mapper graph.

We now switch to the problem of designing filter functions
automatically for Mapper graphs using Soft Mapper. To
2

Differentiable Mapper

6. Conditional risk optimization with respect
to parametersanswer this ill-posed problem, we propose to look for filter
functions that are optimal with respect to some topologicalcriteria associated to their (Soft)Mapper graphs. In particular, we focus on topological losses based on persistenthomology.

Now that we have properly defined risks associated to Soft
Mapper distributions, we study in this section the convergence properties of filter optimization schemes minimizing
such risks.

5.1. Topological signature for Mapper graphs
We now define a filtration function on Mapper graphs
in order to compute extended persistence diagrams. Let
F(Xn , R) be the space of real valued functions defined on
the point cloud Xn . For a function F ∈ F(Xn , R), we first
associate a filtration ϕ to some K ∈ im(MapComp) with:∀σ ∈ K : ϕ(σ) = maxc∈σPx∈c F (x)card(c)6.1. Problem setting
Let us introduce a parameterized family of functions {fθ :Xn → R, θ ∈ Rs }. In order to simplify notations, we
assume in the following of the article that the function F
used to compute persistence diagrams and the filter functionfθ used to design cover assignments are the same, F = fθ .
Let A be a cover assignment scheme whose joint distributionPθ depends on the filter function fθ .

,that is, node filtration values are defined as the averagefilter values of the data points associated to the node, andedge filtration values are computed as the maximum of theirnode values. Then, we compute the extended persistence
diagram (which we consider as a subset of R2 ) of thefiltered simplicial complex (K, ϕ). We denote by MapPers
the function that takes a Mapper graph and a scalar function
on Xn , and then outputs the persistence diagram:

Our goal is to find the optimal set of parameters θ̄ thatminimizes the topological risk associated to MapComp(A),when fθ is used to define the filtration values on the Mapper
graphs. In other words, if we denote:
L : Rs −→ R
θ 7−→ Eθ (L(A, fθ )|Xn ),(1)

our aim is to find a minimizer of L. Note that in the definition of L, the expectation depends on θ because the distribution of A also depends on it.

2

MapPers : K × F(Xn , R) −→ P(R ).

In order to prove guarantees about minimizing L, we follow [9], which uses the theoretical background introducedin [10], in which the authors prove that stochastic gradient descent algorithms converge under certain conditions.
To use this framework, it suffices to prove two points (seeCorollary 5.9. in [10]):Persistence specific loss. Now, we introduce a genericnotation for a loss function—or, more simply, a statistic—that associates a real value to any extended persistence
diagram. Denoting P D as the set of subsets of R2 consisting of a finite number of points outside the diagonal∆ = {(x, x) : x ∈ R}, such a function can be written asℓ : P D −→ R.

• L is definable in an o-minimal structure (see [11]),5.2. Statistical risk of the topological signatureassociated to Soft Mapper• L is locally Lipschitz.
6.2. Theoretical guarantees on the convergence of a
gradient descent scheme

We finally compute the loss associated to a Mapper graphwith the function

Under regularity assumptions on the parameterized familyof filter functions F = {fθ : Xn −→ R, θ ∈ Rs }, we now
show that the risk L in Equation (1) is definable and smooth.
For a detailed proof, see [12].

n×r

L : {0, 1}
× F(Xn , R) −→ R(e, F ) 7−→ ℓ (MapPers (MapComp(e), F )) .

Theorem 6.1. Suppose that there exists an o-minimal structure S such that:

Then, we define the risk of a Soft Mapper MapComp(A) by
integrating the loss according to the distribution of the Soft
Mapper, or equivalently according to the distribution of thecover assignment scheme:
E (L(A, F )|Xn ) =X• for every x ∈ Xn , the function θ 7→ fθ (x) is definable
in S and is locally Lipschitz,• for every m ∈ N, the restriction of ℓ to the set of(extended) persistence diagrams of size m is definable
in S and is locally Lipschitz,

L(e, F ) · P(A = e|Xn ).

e∈{0,1}n×r

3

Differentiable Mapper
n×r• for every e ∈ {0, 1}, the function θ 7→ Pθ (A =e|Xn ) is definable in S and is locally Lipschitz.
Then L is definable in S and is locally Lipschitz.

7. Numerical Experiments
An application where we can use the Soft Mapper optimization setting is finding linear filters in order to skeletonize
3-dimensional shapes with Mapper graphs. Here, our dataset
Xn consists each time of a point cloud embedded in R3 . The
different point clouds we study are displayed (as meshes) in
Figure 1. The parametric family of functions is linear, i.e.,equal to {fθ : x 7→ ⟨x, θ⟩, θ ∈ R3 }, and the cover assignment scheme Aδ is the smooth relaxation of the standard
case, with δ = 10−2 · (maxx∈Xn fθ (x) − minx∈Xn fθ (x)).
The cover of the image space is given by intervals of thesame length, such that consecutive intervals have a fixed percentage of their length in common. The clustering algorithm
for the three shapes is KMeans.

Figure 1. Meshes of 3-dimensional point clouds representing fromleft to right: a human, an octopus and a table.

Figure 4. Regular Mapper graphs computed with the optimized
filter function, corresponding, from left to right, to: the human, theoctopus and the table. Vertices are colored using the mean valueof the filter function in the corresponding clusters.

Objective. Intuitively, the optimal directions to filter the
3-dimensional shapes (in a topological sense) are: the vertical direction for the human, the parallel direction to thetentacles for the octopus and the perpendicular direction to
the upper surface for the table. This can be justified by thefact that these directions induce Mapper graphs with more
topological structures. To find θ̄, we use the opposite of
the L1 total (regular) persistence as a persistence specificloss ℓ, each time taking the diagonal as the initial direction,i.e. θ0 = ( √13 , √13 , √13 )T . The learning curves for each3-dimensional shape are displayed in Figure 2.

Figure 3. Regular Mapper graphs computed with the initial filter
function, corresponding, from left to right, to: the human, theoctopus and the table. Vertices are colored using the mean valueof the filter function in the corresponding clusters.

Qualitative assessment. One can see, in Figures 3 and 4,
that the regular Mapper graphs built with the initial and final(optimized) filter functions show clear improvement in theability of the graphs to act as skeletons of the original point
clouds. The third shape, representing a table, is particularlyinteresting. Indeed, the optimal direction that we captured isdifferent from the first and the second principal components
computed by PCA, since the principal plane of the point
cloud is given by the surface of the table.

8. Discussion
In this work, we have introduced Soft Mapper, a distributional and smoother version of the standard Mapper graph,with provable convergence guarantees using persistencebased losses and risks. Our case study in this article wasfinding an optimal filter function, among a parameterizedfamily of functions, in order to construct regular Mapper
graphs incorporating an optimized and maximal amountof topological information. We then produced examples
of such optimization processes on real 3D shape data, forwhich we were able to obtain structured Mapper representations in an unsupervised way.

Figure 2. Learning curves for the 3-dimensional shapes corresponding, from left to right, to: the human, the octopus and thetable.

4

Differentiable Mapper

References
[1]

[2]

[3]

[4]

[5]

[6]

[7]

[8]

[9]

[10]

[11]
[12]

G. Singh, F. Mémoli, G. E. Carlsson, et al., “Topologicalmethods for the analysis of high dimensional data setsand 3d object recognition.,” PBG@ Eurographics, vol. 2,
pp. 091–100, 2007.
T. Wang, T. Johnson, J. Zhang, and K. Huang, “Topological methods for visualization and analysis of high dimensional single-cell rna sequencing data,” in BIOCOMPUTING 2019: Proceedings of the Pacific Symposium, World
Scientific, 2018, pp. 350–361.
S. Zechel, P. Zajac, P. Lönnerberg, C. F. Ibáñez, and S.
Linnarsson, “Topographical transcriptome mapping of themouse medial ganglionic eminence by spatially resolved
rna-seq,” Genome biology, vol. 15, pp. 1–12, 2014.
S. Mitra and K. Rao JV, “Experiments on fraud detection use case with qml and tda mapper,” in 2021 IEEE
International Conference on Quantum Computing and Engineering (QCE), 2021, pp. 471–472. DOI: 10.1109/
QCE52317.2021.00083.
B. B. Joseph, T. Pham, and C. Hastings, “Topological data
analysis in conjunction with traditional machine learningtechniques to predict future mdap pm ratings,” in Acquisition Research Program, 2021.
Z. Wang, “Exploration of topological data analysis in 3d
printing,” in 2020 International Conference on Information
Science, Parallel and Distributed Systems (ISPDS), IEEE,
2020, pp. 150–153.
P. Rosen, M. Hajij, J. Tu, T. Arafin, and L. Piegl, “Inferring
quality in point cloud-based 3d printed objects using topological data analysis,” arXiv preprint arXiv:1807.02921,
2018.
A. Rizvi, P. Cámara, E. Kandror, et al., “Single-cell topological RNA-seq analysis reveals insights into cellular differentiation and development,” Nature Biotechnology, vol. 35,
pp. 551–560, 2017.
M. Carriere, F. Chazal, M. Glisse, Y. Ike, H. Kannan, and Y.
Umeda, “Optimizing persistent homology based functions,”in International conference on machine learning, PMLR,
2021, pp. 1294–1303.
D. Davis, D. Drusvyatskiy, S. Kakade, and J. D. Lee,
“Stochastic subgradient method converges on tame functions,” Foundations of computational mathematics, vol. 20,
no. 1, pp. 119–154, 2020.
M. Coste, An introduction to o-minimal geometry. Istituti
editoriali e poligrafici internazionali Pisa, 2000.
Z. Oulhaj, M. Carrière, and B. Michel, “Differentiablemapper for topological optimization of data representation,”
arXiv preprint arXiv:2402.12854, 2024.

5