MapperInteractivePlotter

gtda.mapper.MapperInteractivePlotter(pipeline, data, clone_pipeline=True)[source]

Plot Mapper graphs in a Jupyter session, with interactivity on pipeline parameters.

Provides functionality to interactively update parameters from the cover, clustering and graph construction steps defined in pipeline. An interactive widget is produced when calling plot. After interacting with the widget, the current state of all outputs which may have been altered can be retrieved via one of the attributes listed below.

Parameters
  • pipeline (MapperPipeline object) – Mapper pipeline to act on to data.

  • data (array-like of shape (n_samples, n_features)) – Data used to generate the Mapper graph. Can be a pandas dataframe.

  • clone_pipeline (bool, optional, default: True) – If True, the input pipeline is cloned before computing the Mapper graph to prevent unexpected side effects from in-place parameter updates.

gtda.mapper.graph_

Current state of the graph displayed by the widget.

Type

igraph.Graph object

gtda.mapper.pipeline_

Current state of the Mapper pipeline.

Type

MapperPipeline object

gtda.mapper.color_features_

Values of the features of interest for each entry in data, as produced according to color_data and color_features when calling plot. Not changed by interacting with the widget.

Type

array-like of shape (n_samples, n_features)

gtda.mapper.node_summaries_

Current values of the summaries computed for each node and used as node colours in the figure. Produced according to node_color_statistic, see plot.

Type

array-like of shape (n_nodes, n_features)

gtda.mapper.figure_

Current figure representing the Mapper graph with appropriate node colouring and size.

Type

plotly.graph_objects.FigureWidget object

Examples

Instantiate the plotter object on a pipeline and data configuration, and call plot to display the widget in a Jupyter session:

>>> import numpy as np
>>> np.random.seed(1)
>>> from gtda.mapper import make_mapper_pipeline, MapperInteractivePlotter
>>> pipeline = make_mapper_pipeline()
>>> data = np.random.random((100, 3))
>>> plotter = MapperInteractivePlotter(pipeline, data)
>>> plotter.plot()

After interacting with the widget, inspect the composition of a node with “Node ID” displayed as 0 in the hovertext:

>>> plotter.graph_.vs[0]["node_elements"]
array([70])

Write the current figure to a file using Plotly: >>> fname = “current_figure” >>> plotter.fig_.write_html(fname + “.html”) >>> plotter.fig_.write_image(fname + “.svg”) # Requires psutil

See also

plot_interactive_mapper_graph, plot_static_mapper_graph, gtda.mapper.pipeline.make_mapper_pipeline

References

1

igraph.Graph.layout documentation.