PersistenceEntropy

class gtda.diagrams.PersistenceEntropy(normalize=False, nan_fill_value=- 1.0, n_jobs=None)[source]

Persistence entropies of persistence diagrams.

Given a persistence diagram consisting of birth-death-dimension triples [b, d, q], subdiagrams corresponding to distinct homology dimensions are considered separately, and their respective persistence entropies are calculated as the (base 2) Shannon entropies of the collections of differences d - b (“lifetimes”), normalized by the sum of all such differences. Optionally, these entropies can be normalized according to a simple heuristic, see normalize.

Important notes:

  • Input collections of persistence diagrams for this transformer must satisfy certain requirements, see e.g. fit.

  • By default, persistence subdiagrams containing only triples with zero lifetime will have corresponding (normalized) entropies computed as numpy.nan. To avoid this, set a value of nan_fill_value different from None.

Parameters
  • normalize (bool, optional, default: False) – When True, the persistence entropy of each diagram is normalized by the logarithm of the sum of lifetimes of all points in the diagram. Can aid comparison between diagrams in an input collection when these have different numbers of (non-trivial) points. 1

  • nan_fill_value (float or None, optional, default: -1.) – If a float, (normalized) persistence entropies initially computed as numpy.nan are replaced with this value. If None, these values are left as numpy.nan.

  • n_jobs (int or None, optional, default: None) – The number of jobs to use for the computation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors.

homology_dimensions_

Homology dimensions seen in fit, sorted in ascending order.

Type

tuple

References

1

A. Myers, E. Munch, and F. A. Khasawneh, “Persistent Homology of Complex Networks for Dynamic State Detection”; Phys. Rev. E 100, 022314, 2019; DOI: 10.1103/PhysRevE.100.022314.

__init__(normalize=False, nan_fill_value=- 1.0, n_jobs=None)[source]

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

fit(X, y=None)[source]

Store all observed homology dimensions in homology_dimensions_. Then, return the estimator.

This method is here to implement the usual scikit-learn API and hence work in pipelines.

Parameters
  • X (ndarray of shape (n_samples, n_features, 3)) – Input data. Array of persistence diagrams, each a collection of triples [b, d, q] representing persistent topological features through their birth (b), death (d) and homology dimension (q). It is important that, for each possible homology dimension, the number of triples for which q equals that homology dimension is constants across the entries of X.

  • 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, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (ndarray of shape (n_samples, n_features, 3)) – Input data. Array of persistence diagrams, each a collection of triples [b, d, q] representing persistent topological features through their birth (b), death (d) and homology dimension (q). It is important that, for each possible homology dimension, the number of triples for which q equals that homology dimension is constants across the entries of X.

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

Returns

Xt – Persistence entropies: one value per sample and per homology dimension seen in fit. Index i along axis 1 corresponds to the i-th homology dimension in homology_dimensions_.

Return type

ndarray of shape (n_samples, n_homology_dimensions)

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

transform(X, y=None)[source]

Compute the persistence entropies of diagrams in X.

Parameters
  • X (ndarray of shape (n_samples, n_features, 3)) – Input data. Array of persistence diagrams, each a collection of triples [b, d, q] representing persistent topological features through their birth (b), death (d) and homology dimension (q). It is important that, for each possible homology dimension, the number of triples for which q equals that homology dimension is constants across the entries of X.

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

Returns

Xt – Persistence entropies: one value per sample and per homology dimension seen in fit. Index i along axis 1 corresponds to the i-th homology dimension in homology_dimensions_.

Return type

ndarray of shape (n_samples, n_homology_dimensions)