Nerve

class gtda.mapper.Nerve(min_intersection=1, store_edge_elements=False, contract_nodes=False)[source]

1-skeleton of the nerve of a refined Mapper cover, i.e. the Mapper graph.

This transformer is the final step in the gtda.mapper.pipeline.MapperPipeline objects created by gtda.mapper.make_mapper_pipeline. It corresponds the last two arrows in this diagram.

Parameters
  • min_intersection (int, optional, default: 1) – Minimum size of the intersection, between data subsets associated to any two Mapper nodes, required to create an edge between the nodes in the Mapper graph. Must be positive.

  • store_edge_elements (bool, optional, default: False) – Whether the indices of data elements associated to Mapper edges (i.e. in the intersections allowed by min_intersection) should be stored in the igraph.Graph object output by fit_transform. When True, might lead to a large igraph.Graph object.

  • contract_nodes (bool, optional, default: False) – If True, any node representing a cluster which is a strict subset of the cluster corresponding to another node is eliminated, and only one maximal node is kept.

graph_

Mapper graph obtained from the input data. Created when fit is called.

Type

igraph.Graph object

__init__(min_intersection=1, store_edge_elements=False, contract_nodes=False)[source]

Initialize self. See help(type(self)) for accurate signature.

fit(X, y=None)[source]

Compute the Mapper graph as in fit_transform, but store the graph as graph_ and return the estimator.

Parameters
  • X (list of list of tuple) – See fit_transform.

  • y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.

Returns

self

Return type

object

fit_transform(X, y=None)[source]

Construct a Mapper graph from a refined Mapper cover.

Parameters
  • X (ndarray of shape (n_samples,)) –

    Cluster labels describing a refined cover of a dataset produced by the clustering step of a gtda.mapper.MapperPipeline, as depicted in this diagram. Each entry in X is a tuple of pairs of the form (pullback_set_label, partial_cluster_label) where partial_cluster_label is a cluster label within the pullback cover set identified by pullback_set_label. The unique pairs correspond to nodes in the output graph.

  • y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.

Returns

graph – Undirected Mapper graph according to X and min_intersection. Each node is an igraph.Vertex object with attributes "pullback_set_label", "partial_cluster_label" and "node_elements". Each edge is an igraph.Edge object with a "weight" attribute which is equal to the size of the intersection between the data subsets associated to its two nodes. If store_edge_elements is True each edge also has an additional attribute "edge_elements".

Return type

igraph.Graph object

get_params(deep=True)

Get parameters for this estimator.

Parameters

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params – Parameter names mapped to their values.

Return type

mapping of string to any

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**params (dict) – Estimator parameters.

Returns

self – Estimator instance.

Return type

object