MapperInteractivePlotter(pipeline, data, clone_pipeline=True)¶
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.
MapperPipelineobject) – 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.
Current state of the graph displayed by the widget.
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.
array-like of shape (n_samples, n_features)
Current values of the summaries computed for each node and used as node colours in the figure. Produced according to node_color_statistic, see
array-like of shape (n_nodes, n_features)
Current figure representing the Mapper graph with appropriate node colouring and size.
Instantiate the plotter object on a pipeline and data configuration, and call
plotto 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["node_elements"] array()