Visualizing a kepler-mapper graph with Plotly

This notebook illustrates a simple example to define a kepler-mapper graph and display it as an instance of the Plotly FigureWidget or Figure class.


In [1]:
import kmapper as km
import sklearn
from sklearn import datasets
#for Plotly visualization import:
from kmapper.plotlyviz import plotlyviz
from kmapper.plotlyviz import *
import plotly.graph_objs as go

In [2]:
data, labels = datasets.make_circles(n_samples=5000, noise=0.05, factor=0.3)

# Initialize
mapper = km.KeplerMapper(verbose=0)

# Fit to and transform the data
lens = mapper.fit_transform(data, projection=[0])

# Create dictionary called 'simplicial_complex' with nodes, edges and meta-information
simplicial_complex = mapper.map(lens, X=data,
                                clusterer=sklearn.cluster.DBSCAN(eps=0.1, min_samples=10),
                                cover=km.Cover(n_cubes=20, perc_overlap=0.1))

In [3]:
title = 'Kepler-Mapper graph  for circles dataset with<br> Kamada-Kawai layout'
plotlyviz(simplicial_complex, title=title)



In [ ]: