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 bygtda.mapper.make_mapper_pipeline
. It corresponds the last two arrows in this diagram.This transformer is not intended for direct use.
- 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 theigraph.Graph
object output byfit_transform
. WhenTrue
, might lead to a largeigraph.Graph
object.contract_nodes (bool, optional, default:
False
) – IfTrue
, 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 asgraph_
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 (list of list of tuple) –
Data structure describing a cover of a dataset (e.g. as depicted in this diagram) produced by the clustering step of a
gtda.mapper.MapperPipeline
. Each sublist corresponds to a (non-empty) pullback cover set – equivalently, to a cover set in the filter range which has non-empty preimage. It contains triples of the form(pullback_set_label, partial_cluster_label, node_elements)
wherepartial_cluster_label
is a cluster label within the pullback cover set identified bypullback_set_label
, andnode_elements
is an array of integer indices. To each pair(pullback_set_label, partial_cluster_label)
there corresponds a unique node in the output Mapper graph. This node represents the data subset defined by the indices innode_elements
.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 anigraph.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 isTrue
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