persim.PersImage

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. 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.
__init__(pixels=(20, 20), spread=None, specs=None, kernel_type='gaussian', weighting_type='linear', verbose=True)[source]

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

Methods

__init__([pixels, spread, specs, …]) Initialize self.
fit_transform(X[, y]) Fit to data, then transform it.
kernel([spread]) This will return whatever kind of kernel we want to use.
show(imgs[, ax]) Visualize the persistence image
to_landscape(diagram) Convert a diagram to a landscape (b,d) -> (b, d-b)
transform(diagrams) Convert diagram or list of diagrams to a persistence image.
weighting([landscape]) Define a weighting function, for stability results to hold, the function must be 0 at y=0.
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 (numpy array of shape [n_samples, n_features]) – Training set.
  • y (numpy array of shape [n_samples]) – Target values.
Returns:

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

kernel(spread=1)[source]

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)

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.
weighting(landscape=None)[source]

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