How to use 2D data

An introduction of using aleady dimension reduced data.

In this tutorial, we visualize iris dataset that was reduced 2d.

  • How to use 2d data.


In [1]:
import numpy as np

from sklearn.datasets import load_iris

from renom_tda.topology import Topology
from renom_tda.lens import PCA


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 =

Create test data

Next, we create test data.

In [3]:
topology = Topology()
metric = None
lens = [PCA(components=[0, 1])]
topology.fit_transform(metric=metric, lens=lens)
projected by PCA.
In [4]:
(150, 2)
In [5]:
np.savetxt("test.csv", topology.point_cloud)

Import test data

In [6]:
data = np.loadtxt("test.csv")
In [7]:
(150, 2)
In [8]:
topology = Topology()

Create point cloud

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

If you wan’t to use aleady 2d data, you set parameters as follow.

In [9]:
topology.fit_transform(metric=None, lens=None)

Mapping to topological space

In [10]:, overlap=0.5, eps=0.1, min_samples=3)
created 72 nodes.
created 201 edges.

Colorize & Show

In [11]:
topology.color(target, color_method="mode", normalize=True), 10), node_size=10, edge_width=2)