API Reference¶

persim.
bottleneck
(dgm1, dgm2, matching=False)[source]¶ Perform the Bottleneck distance matching between persistence diagrams. Assumes first two columns of S and T are the coordinates of the persistence points, but allows for other coordinate columns (which are ignored in diagonal matching)
Parameters:  dgm1: Mx(>=2)
array of birth/death pairs for PD 1
 dgm2: Nx(>=2)
array of birth/death paris for PD 2
 matching: bool, default False
if True, return matching information
Returns:  d: float
bottleneck distance between dgm1 and dgm2
 matching: tuples of matched indices
if input matching=True, then return matching
 D: (N+M)x(N+M) crosssimilarity matrix
if input matching=True, then return D

persim.
sliced_wasserstein
(PD1, PD2, M=50)[source]¶ Implementation of Sliced Wasserstein distance as described in Sliced Wasserstein Kernel for Persistence Diagrams by Mathieu Carriere, Marco Cuturi, Steve Oudot (https://arxiv.org/abs/1706.03358)
Parameters:  PD1: np.array size (m,2)
Persistence diagram
 PD2: np.array size (n,2)
Persistence diagram
 M: int, default is 50
Iterations to run approximation.
Returns:  sw: float
Sliced Wasserstein distance between PD1 and PD2

persim.
heat
(dgm1, dgm2, sigma=0.4)[source]¶ Return the pseudometric between two diagrams based on the continuous heat kernel as described in “A Stable MultiScale Kernel for Topological Machine Learning” by Jan Reininghaus, Stefan Huber, Ulrich Bauer, and Roland Kwitt (CVPR 2015)
Parameters:  dgm1: np.array (m,2)
A persistence diagram
 dgm2: np.array (n,2)
A persistence diagram
 sigma: float
Heat diffusion parameter (larger sigma makes blurrier)
 Returns
 ——–
 dist: float
heat kernel distance between dgm1 and dgm2

class
persim.
PersImage
(pixels=(20, 20), spread=None, specs=None, kernel_type='gaussian', weighting_type='linear', verbose=True)[source]¶ Initialize a persistence image generator.
Parameters:  pixels : pair of ints like (int, int)
Tuple representing number of pixels in return image along x and y axis.
 spread : float
Standard deviation of gaussian kernel
 specs : dict
Parameters for shape of image with respect to diagram domain. This is used if you would like images to have a particular range.
 kernel_type : string or …
TODO: Implement this feature. Determine which type of kernel used in the convolution, or pass in custom kernel. Currently only implements Gaussian.
 weighting_type : string or …
TODO: Implement this feature. Determine which type of weighting function used, or pass in custom weighting function. Currently only implements linear weighting.

transform
(diagrams)[source]¶ Convert diagram or list of diagrams to a persistence image.
Parameters:  diagrams : list of or singleton diagram, list of pairs. [(birth, death)]
Persistence diagrams to be converted to persistence images. It is assumed they are in (birth, death) format. Can input a list of diagrams or a single diagram.