Amplitude

class gtda.diagrams.Amplitude(metric='landscape', metric_params=None, order=2.0, n_jobs=None)[source]

Amplitudes of persistence diagrams.

For each persistence diagram in a collection, a vector of amplitudes or a single scalar amplitude is calculated according to the following steps:

  1. The diagram is partitioned into subdiagrams according to homology dimension.

  2. The amplitude of each subdiagram is calculated according to the parameters metric and metric_params. This gives a vector of amplitudes, \(\mathbf{a} = (a_{q_1}, \ldots, a_{q_n})\) where the \(q_i\) range over the available homology dimensions.

  3. The final result is either \(\mathbf{a}\) itself or a norm of \(\mathbf{a}\), specified by the parameter order.

Parameters
  • metric ('bottleneck' | 'wasserstein' | 'landscape' | 'betti' | 'heat' | 'silhouette' | 'persistence_image', optional, default: 'landscape') –

    Distance or dissimilarity function used to define the amplitude of a subdiagram as its distance from the (trivial) diagonal diagram:

    • 'bottleneck' and 'wasserstein' refer to the identically named perfect-matching–based notions of distance.

    • 'landscape' refers to the \(L^p\) distance between persistence landscapes.

    • 'betti' refers to the \(L^p\) distance between Betti curves.

    • 'heat' refers to the \(L^p\) distance between Gaussian-smoothed diagrams.

    • 'silhouette' refers to the \(L^p\) distance between silhouettes.

    • 'persistence_image' refers to the \(L^p\) distance between Gaussian-smoothed diagrams represented on birth-persistence axes.

  • metric_params (dict or None, optional, default: None) –

    Additional keyword arguments for the metric function (passing None is equivalent to passing the defaults described below):

    • If metric == 'bottleneck' there are no available arguments.

    • If metric == 'wasserstein' the only argument is p (float, default: 2.).

    • If metric == 'landscape' the available arguments are p (float, default: 2.), n_bins (int, default: 100) and n_layers (int, default: 1).

    • If metric == 'betti' the available arguments are p (float, default: 2.) and n_bins (int, default: 100).

    • If metric == 'heat' the available arguments are p (float, default: 2.), sigma (float, default: 1.) and n_bins (int, default: 100).

    • If metric == 'silhouette' the available arguments are p (float, default: 2.), order (float, default: 1.) and n_bins (int, default: 100).

    • If metric == 'persistence_image' the available arguments are p (float, default: 2.), sigma (float, default: 1.), n_bins (int, default: 100) and weight_function (callable or None, default: None).

  • order (float or None, optional, default: 2.) – If None, transform returns for each diagram a vector of amplitudes corresponding to the dimensions in homology_dimensions_. Otherwise, the \(p\)-norm of these vectors with \(p\) equal to order is taken.

  • 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.

effective_metric_params_

Dictionary containing all information present in metric_params as well as on any relevant quantities computed in fit.

Type

dict

homology_dimensions_

Homology dimensions seen in fit, sorted in ascending order.

Type

list

Notes

To compute amplitudes without first splitting the computation between different homology dimensions, data should be first transformed by an instance of ForgetDimension.

__init__(metric='landscape', metric_params=None, order=2.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_ and compute effective_metric_params. 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).

  • 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).

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

Returns

Xt – Amplitudes or amplitude vectors of the diagrams in X. In the second case, 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) if order is None, else (n_samples, 1)

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 amplitudes or amplitude vectors 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).

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

Returns

Xt – Amplitudes or amplitude vectors of the diagrams in X. In the second case, 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) if order is None, else (n_samples, 1)