scott.topology.representations

class scott.topology.representations.PersistenceDiagram(homology_dims=[0, 1])[source]

Bases: object

A wrapper object for the data housed in a persistence diagram for the specified homology dimensions. Main attribute (persistence_points) is a Dict[int, np.array] that maps a homology dimension key to a np.array that contains (birth,death) tuples for all the persistence pairs.

homology_dims

Dimensions of the homology groups to compute (e.g., [0, 1] for H_0 and H_1).

Type:

List[int], default=[0, 1]

_persistence_points

A dictionary that maps the homology dimension to a np.array of its persistence pairs. Each np.array contains tuples of (birth, death) values for each persistence pair. Note that the attribute homology_dims must be a subset of the list of keys (hom. dims.) in this dictionary. Initialized to None, set using setter method.

Type:

None or Dict[int, np.array]

__init__(homology_dims=[0, 1])[source]

Initializes an instance of the PersistenceDiagram class.

property persistence_pts: Dict[int, array]

Get the PersistenceDiagram’s dictionary of persistence points. :returns: A dictionary that maps np.arrays of persistence point tuples (values) to each homology dimenion (key). Will return None if persistence_pts have not yet been set. :rtype: Dict[int,np.array]

get_pts_for_dim(dimension: int) array[source]
plot()[source]

Plots the persistence diagram using Gudhi’s built-in functionality.

class scott.topology.representations.PersistenceImage(homology_dims=[0, 1], bandwidth=1.0, weight=<function PersistenceImage.<lambda>>, resolution=[20, 20])[source]

Bases: object

A wrapper object for the data housed in the image vectorization of a persistence diagram.

homology_dims

Dimensions of the homology groups to compute (e.g., [0, 1] for H_0 and H_1).

Type:

List[int], default=[0, 1]

bandwidth

Controls the Gaussian kernel for the probability distribution calculated for each point on the birth/persistence diagram. See gudhi documentation for more information.

Type:

double, default = 1.0

weight

Defines the weight function used to compute the weighted sum of the probability distributions for each point on the bith/persistence diagram, i.e. the persistence surface. Default is a constant function. Other common choices are a linear function or a bump function, which put greater emphasis on points with longer persistence. See gudhi documentation for more information.

Type:

function, default = lambda x: 1

resolution

The dimensions of the persistence image in pixels.

Type:

List[int, int], default = [20,20]

_pixels

A dictionary that maps each homology dimension to its persistence image in the form of a np.array. Each np.array has shape (resolution[0] * resolution[1], 1), and contains the values of the persistence surface at each pixel. Initialized to None, set using setter method.

Type:

Dict[int, np.array]

__init__(homology_dims=[0, 1], bandwidth=1.0, weight=<function PersistenceImage.<lambda>>, resolution=[20, 20])[source]

Initializes an object of the PersistenceImage class.

property pixels: Dict[int, array]

Getter for the dictionary of persistence images.

get_pixels_for_dim(dimension: int) array[source]

Returns a np.array representing the persistence image for the specified dimension.

class scott.topology.representations.PersistenceLandscape(homology_dims=[0, 1], num_functions=5, resolution=1000)[source]

Bases: object

A wrapper object for the data housed in a persistence landscape for the specified homology dimensions.

homology_dims

Dimensions of the homology groups to compute (e.g., [0, 1] for H_0 and H_1).

Type:

List[int], default=[0, 1]

num_functions

The number of landscape functions to compute for each homology dimension. These are usually denoted lambda_1, lambda_2, …, lambda_{num_functions}. Recall that for each successive landscape function, the values of the highest peak function at each x-value is removed from consideration.

Type:

int, default=5

resolution

Determines the number of samples for the piece-wise landscape functions (i.e. how many points are calculated).

Type:

int, default = 1000

_functions

A dictionary that maps the homology dimension to a np.array of its landscape functions. Each np.array contains {num_functions * resolution} floats, which are the {resolution} number of samples for all {num_functions} landscape functions concatenated together. Initialized to None, set using setter method.

Type:

Dict[int, np.array]

__init__(homology_dims=[0, 1], num_functions=5, resolution=1000)[source]

Initializes an object of the PersistenceDiagram class.

property functions: Dict[int, array]

Getter for the complete dictionary of landscape functions.

get_fns_for_dim(dimension: int) array[source]

Returns a np.array of concatenated landscape functions for the specified dimension.

get_fn_for_dim(dimension: int, fn_num: int) array[source]

Returns a list of points for landscape function associated with the given dimension and function number.