# giotto.diagrams.HeatKernel¶

class giotto.diagrams.HeatKernel(sigma, n_values=100, n_jobs=None)

Convolution of persistence diagrams with a Gaussian kernel.

Based on ideas in [1]. Given a persistence diagram consisting of birth-death-dimension triples [b, d, q], subdiagrams corresponding to distinct homology dimensions are considered separately and regarded as sums of Dirac deltas. Then, the convolution with a Gaussian kernel is computed over a rectangular grid of locations evenly sampled from appropriate ranges of the filtration parameter. The same is done with the reflected images of the subdiagrams about the diagonal, and the difference between the results of the two convolutions is computed. The result can be thought of as a raster image.

Parameters
sigmafloat

Standard deviation for Gaussian kernel.

n_valuesint, optional, default: 100

The number of filtration parameter values, per available homology dimension, to sample during fit.

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

Attributes
homology_dimensions_list

Homology dimensions seen in fit.

samplings_dict

For each number in homology_dimensions_, a discrete sampling of filtration parameters, calculated during fit according to the minimum birth and maximum death values observed across all samples.

Notes

The samplings in samplings_ are in general different between different homology dimensions. This means that the (i, j)-th pixel of a persistence image in homology dimension q typically arises from a different pair of parameter values to the (i, j)-th pixel of a persistence image in dimension q’.

References

1

J. Reininghaus, S. Huber, U. Bauer, and R. Kwitt, “A Stable Multi-Scale Kernel for Topological Machine Learning”; 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4741–4748, 2015; doi: 10.1109/CVPR.2015.7299106.

Methods

 fit(self, X[, y]) Store all observed homology dimensions in homology_dimensions_ and, for each dimension separately, store evenly sample filtration parameter values in samplings_. fit_transform(self, X[, y]) Fit to data, then transform it. get_params(self[, deep]) Get parameters for this estimator. set_params(self, \*\*params) Set the parameters of this estimator. transform(self, X[, y]) Compute raster images obtained from diagrams in X by convolution with a Gaussian kernel.
__init__(self, sigma, n_values=100, n_jobs=None)

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

fit(self, X, y=None)

Store all observed homology dimensions in homology_dimensions_ and, for each dimension separately, store evenly sample filtration parameter values in samplings_. Then, return the estimator.

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

Parameters
Xndarray, 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).

yNone

There is no need for a target in a transformer, yet the pipeline API requires this parameter.

Returns
selfobject
fit_transform(self, 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
Xnumpy array of shape [n_samples, n_features]

Training set.

ynumpy array of shape [n_samples]

Target values.

Returns
X_newnumpy array of shape [n_samples, n_features_new]

Transformed array.

get_params(self, deep=True)

Get parameters for this estimator.

Parameters
deepboolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsmapping of string to any

Parameter names mapped to their values.

set_params(self, **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.

Returns
self
transform(self, X, y=None)

Compute raster images obtained from diagrams in X by convolution with a Gaussian kernel.

Parameters
Xndarray, 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).

yNone

There is no need for a target in a transformer, yet the pipeline API requires this parameter.

Returns
Xtndarray, shape (n_samples, n_homology_dimensions, n_values, n_values)

Raster images: one image per sample and per homology dimension seen in fit. Index i along axis 1 corresponds to the i-th homology dimension in homology_dimensions_.