How to use ReNom TDA

An introduction of how to use ReNom TDA.

In this tutorial, we visualize iris dataset. you can learn following points.

  • How to create topology using ReNom TDA.


In [1]:
from sklearn.cluster import DBSCAN
from sklearn.datasets import load_iris

from renom.tda.topology import Topology, SearchableTopology
from renom.tda.lens import PCA

Load dataset

Next, we have to load iris dataset. To accomplish this, we’ll use the load_iris module included in the scikit-learn package.

The iris dataset consists of 150 data and data has 4 columns.

In [2]:
iris = load_iris()

data =
target =

Define topology instance

Next, we have to define topology instance.

ReNom TDA has two type of Topology class, Topology and SearchableTopology.

Topology class has basic four function, fit_transform, map, color and show.

SearchableTopology class extend Topology class. It has more three function, regist_categorical_data, search and get_hypercubes.

SearchableTopology can search data from categorical data.

If you want more information, see API refarence.

In [3]:
topology = Topology()

Create point cloud

Next, we create point cloud that is projected on 2 or 3 dimention space.

We use fit_transform function to project data with two parameter, metric and lens.

Metric is how to measure distance between data. Lens is the axis of projected space.

This tutorial use metric None and lens PCA. This means dimenstion reduction with normal PCA.

In [4]:
metric = None
lens = [PCA(components=[0, 1])]
topology.fit_transform(data, metric=metric, lens=lens)
projected by PCA.
finish fit_transform.

Mapping to topological space

Next, we create topology.

We use map function to map point cloud to topological space.

We set three parameter, resolution, overlap and clusterer.

Resolution means the number of division. It effects the number of nodes.

Overlap means the easiness to connect with each nodes.

Clusterer means the clustering method for data that is in nodes.

In [5]:
clusterer = DBSCAN(eps=0.5, min_samples=3), overlap=0.5, clusterer=clusterer)
mapping start, please wait...
created 64 nodes.
calculating cluster coordination.
calculating edge.
created 160 edges.

Color topology

Next, we colorize topology using color funcion.

In this tutorial, topology is colored by iris label values.

We can select dtype is categorical or numerical and ctype is rgb or gray.

In [6]:
topology.color(target, dtype="categorical", ctype="rgb", normalized=False)

Show topology

Finally, we show topology.

This graph shows that two cluster exists in this dataset.

Small cluster consists of one label and large cluster consists of two different labels.

In [7]:, 10), node_size=10, edge_width=2)