API Reference

class persim.PersImage(pixels=(20, 20), spread=None, specs=None, kernel_type='gaussian', weighting_type='linear', verbose=True)[source]

Initialize a persistence image generator.

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

        "maxBD": float,
        "minBD": float
  • 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.
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.

  • X (numpy array of shape [n_samples, n_features]) – Training set.
  • y (numpy array of shape [n_samples]) – Target values.

X_new (numpy array of shape [n_samples, n_features_new]) – Transformed array.


This will return whatever kind of kernel we want to use. Must have signature (ndarray size NxM, ndarray size 1xM) -> ndarray size Nx1

show(imgs, ax=None)[source]

Visualize the persistence image

static to_landscape(diagram)[source]

Convert a diagram to a landscape (b,d) -> (b, d-b)


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.

Define a weighting function, for stability results to hold, the function must be 0 at y=0.