persim.PersistenceLandscaper

class persim.PersistenceLandscaper(hom_deg: int = 0, start: float = None, stop: float = None, num_steps: int = 500, flatten: bool = False)[source]

A scikit-learn transformer for converting persistence diagrams into persistence landscapes.

Parameters:
  • hom_deg (int) – Homological degree of persistence landscape.

  • start (float, optional) – Starting value of approximating grid.

  • stop (float, optional) – Stopping value of approximating grid.

  • num_steps (int, optional) – Number of steps of approximating grid.

  • flatten (bool, optional) – Determines if the resulting values are flattened.

Examples

First instantiate the PersistenceLandscaper:

>>> from persim import PersistenceLandscaper
>>> pl = PersistenceLandscaper(hom_deg=0, num_steps=10, flatten=True)
>>> print(pl)

PersistenceLandscaper(hom_deg=1,num_steps=10)

The fit() method is first called on a list of (-,2) numpy.ndarrays to determine the start and stop parameters of the approximating grid:

>>> ex_dgms = [np.array([[0,3],[1,4]]),np.array([[1,4]])]
>>> pl.fit(ex_dgms)

PersistenceLandscaper(hom_deg=0, start=0, stop=4, num_steps=10)

The transform() method will then compute the values of the landscape functions on the approximated grid. The flatten flag determines if the output should be a flattened numpy array:

 >>> ex_pl = pl.transform(ex_dgms)
 >>> ex_pl

 array([0.        , 0.44444444, 0.88888889, 1.33333333, 1.33333333,
1.33333333, 1.33333333, 0.88888889, 0.44444444, 0.        ,
0.        , 0.        , 0.        , 0.44444444, 0.88888889,
0.88888889, 0.44444444, 0.        , 0.        , 0.        ])
__init__(hom_deg: int = 0, start: float = None, stop: float = None, num_steps: int = 500, flatten: bool = False)[source]

Methods

__init__([hom_deg, start, stop, num_steps, ...])

fit(X[, y])

Find optimal start and stop parameters for approximating grid.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X[, y])

Construct persistence landscape values.