multipers.filtrations package

Submodules

multipers.filtrations.density module

class multipers.filtrations.density.DTM(masses, metric='euclidean', **_kdtree_kwargs)

Bases: object

Distance To Measure

Parameters:

metric (str)

fit(X, sample_weights=None, y=None)
score_samples(Y, X=None)

Returns the kernel density estimates of each point in Y.

Parameters

Ytensor (m, d)

m points with d dimensions for which the probability density will be calculated

Returns

the DTMs of Y, for each mass in masses.

score_samples_diff(Y)

Returns the kernel density estimates of each point in Y.

Parameters

Ytensor (m, d)

m points with d dimensions for which the probability density will be calculated

Xtensor (n, d), optional

n points with d dimensions to which KDE will be fit. Provided to allow batch calculations in log_prob. By default, X is None and all points used to initialize KernelDensityEstimator are included.

Returns

log_probstensor (m)

log probability densities for each of the queried points in Y

class multipers.filtrations.density.KDE(bandwidth=1, kernel='gaussian', return_log=False)

Bases: object

Fast, scikit-style, and differentiable kernel density estimation, using PyKeops.

Parameters:
  • bandwidth (Any)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

  • return_log (bool)

fit(X, sample_weights=None, y=None)
score_samples(Y, X=None, return_kernel=False)

Returns the kernel density estimates of each point in Y.

Parameters

Ytensor (m, d)

m points with d dimensions for which the probability density will be calculated

Xtensor (n, d), optional

n points with d dimensions to which KDE will be fit. Provided to allow batch calculations in log_prob. By default, X is None and all points used to initialize KernelDensityEstimator are included.

Returns

log_probstensor (m)

log probability densities for each of the queried points in Y

static to_lazy(X, Y, x_weights)
class multipers.filtrations.density.KNNmean(k, metric='euclidean')

Bases: object

Parameters:
  • k (int)

  • metric (str)

fit(x)
score_samples(x)
multipers.filtrations.density._kernel(kernel='gaussian')
Parameters:

kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

multipers.filtrations.density._pts_convolution_pykeops(pts, pts_weights, grid_iterator, kernel='gaussian', bandwidth=0.1, **more_kde_args)

Pykeops convolution

Parameters:
  • pts (ndarray)

  • pts_weights (ndarray)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

multipers.filtrations.density._pts_convolution_sparse_old(pts, pts_weights, grid_iterator, kernel='gaussian', bandwidth=0.1, **more_kde_args)

Old version of convolution_signed_measures. Scikitlearn’s convolution is slower than the code above.

Parameters:
  • pts (ndarray)

  • pts_weights (ndarray)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

multipers.filtrations.density.batch_signed_measure_convolutions(signed_measures, x, bandwidth, kernel)

Input

  • signed_measures: unragged, of shape (num_data, num_pts, D+1) where last coord is weights, (0 for dummy points)

  • x : the points to convolve (num_x,D)

  • bandwidth : the bandwidths or covariance matrix inverse or … of the kernel

  • kernel : “gaussian”, “multivariate_gaussian”, “exponential”, or Callable (x_i, y_i, bandwidth)->float

Output

Array of shape (num_convolutions, (num_axis), num_data, Array of shape (num_convolutions, (num_axis), num_data, max_x_size)

Parameters:

kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

multipers.filtrations.density.convolution_signed_measures(iterable_of_signed_measures, filtrations, bandwidth, flatten=True, n_jobs=1, backend='pykeops', kernel='gaussian', **kwargs)

Evaluates the convolution of the signed measures Iterable(pts, weights) with a gaussian measure of bandwidth bandwidth, on a grid given by the filtrations

Parameters

  • iterable_of_signed_measures : (num_signed_measure) x [ (npts) x (num_parameters), (npts)]

  • filtrations : (num_parameter) x (filtration values)

  • flatten : bool

  • n_jobs : int

Outputs

The concatenated images, for each signed measure (num_signed_measures) x (len(f) for f in filtration_values)

Parameters:
  • flatten (bool)

  • n_jobs (int)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

multipers.filtrations.density.exponential_kernel(x_i, y_j, bandwidth)
multipers.filtrations.density.gaussian_kernel(x_i, y_j, bandwidth)
multipers.filtrations.density.multivariate_gaussian_kernel(x_i, y_j, covariance_matrix_inverse)
multipers.filtrations.density.sinc_kernel(x_i, y_j, bandwidth)

multipers.filtrations.filtrations module

multipers.filtrations.filtrations.CoreDelaunay(points, *, beta=1.0, ks=None, precision='safe', verbose=False, max_alpha_square=inf)

Computes the Delaunay core bifiltration of a point cloud presented in the paper “Core Bifiltration” https://arxiv.org/abs/2405.01214, and returns the (multi-critical) bifiltration as a SimplexTreeMulti. The Delaunay core bifiltration is an alpha complex version of the core bifiltration which is smaller in size. Moreover, along the horizontal line k=1, the Delaunay core bifiltration is identical to the alpha complex.

Input:
  • points: The point cloud as an ArrayLike of shape (n, d) where n is the number of points and d is the dimension of the points.

  • beta: The beta parameter for the Delaunay Core Bifiltration (default 1.0).

  • ks: The list of k-values to include in the bifiltration (default None). If None, the k-values are set to [1, 2, …, n] where n is the number of points in the point cloud. For large point clouds, it is recommended to set ks to a smaller list of k-values to reduce computation time. The values in ks must all be integers, positive, and less than or equal to the number of points in the point cloud.

  • precision: The precision of the computation of the AlphaComplex, one of [‘safe’, ‘exact’, ‘fast’] (default ‘safe’). See the GUDHI documentation for more information.

  • verbose: Whether to print progress messages (default False).

  • max_alpha_square: The maximum squared alpha value to consider when createing the alpha complex (default inf). See the GUDHI documentation for more information.

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • beta (float)

  • ks (Sequence[int] | None)

  • precision (str)

  • verbose (bool)

  • max_alpha_square (float)

Return type:

SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64

multipers.filtrations.filtrations.Cubical(image, **slicer_kwargs)

Computes the cubical filtration of an image. The last axis dimention is interpreted as the number of parameters.

Input:
  • image: ArrayLike of shape (*image_resolution, num_parameters)

  • ** args : specify non-default slicer parameters

Parameters:

image (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

multipers.filtrations.filtrations.DegreeRips(*, points=None, distance_matrix=None, ks=None, threshold_radius=None)

The DegreeRips filtration.

multipers.filtrations.filtrations.DelaunayCodensity(points, bandwidth=None, *, return_log=True, dtm_mass=None, kernel='gaussian', threshold_radius=None, reduce_degree=-1, vineyard=None, dtype=<class 'numpy.float64'>, verbose=False, clear=True, flagify=False)

TODO

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • bandwidth (float | None)

  • return_log (bool)

  • dtm_mass (float | None)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

  • threshold_radius (float | None)

  • reduce_degree (int)

  • vineyard (bool | None)

  • verbose (bool)

  • clear (bool)

  • flagify (bool)

multipers.filtrations.filtrations.DelaunayLowerstar(points, function, *, distance_matrix=None, threshold_radius=None, reduce_degree=-1, vineyard=None, dtype=<class 'numpy.float64'>, verbose=False, clear=True, flagify=False)

Computes the Function Delaunay bifiltration. Similar to RipsLowerstar, but most suited for low-dimensional euclidean data. See [Delaunay bifiltrations of functions on point clouds, Alonso et al] https://doi.org/10.1137/1.9781611977912.173

Input:
  • points or distance_matrix: ArrayLike

  • function : ArrayLike of shape (num_data, )

  • threshold_radius: max edge length of the rips. Defaults at min(max(distance_matrix, axis=1)).

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • function (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • distance_matrix (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • threshold_radius (float | None)

  • reduce_degree (int)

  • vineyard (bool | None)

  • verbose (bool)

  • clear (bool)

  • flagify (bool)

multipers.filtrations.filtrations.RipsCodensity(points, bandwidth=None, *, return_log=True, dtm_mass=None, kernel='gaussian', threshold_radius=None)

Computes the Rips density filtration.

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • bandwidth (float | None)

  • return_log (bool)

  • dtm_mass (float | None)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

  • threshold_radius (float | None)

multipers.filtrations.filtrations.RipsLowerstar(*, points=None, distance_matrix=None, function=None, threshold_radius=None)

Computes the Rips complex, with the usual rips filtration as a first parameter, and the lower star multi filtration as other parameter.

Input:
  • points or distance_matrix: ArrayLike

  • function : ArrayLike of shape (num_data, num_parameters -1)

  • threshold_radius: max edge length of the rips. Defaults at min(max(distance_matrix, axis=1)).

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • distance_matrix (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • function (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • threshold_radius (float | None)

Module contents

multipers.filtrations.CoreDelaunay(points, *, beta=1.0, ks=None, precision='safe', verbose=False, max_alpha_square=inf)

Computes the Delaunay core bifiltration of a point cloud presented in the paper “Core Bifiltration” https://arxiv.org/abs/2405.01214, and returns the (multi-critical) bifiltration as a SimplexTreeMulti. The Delaunay core bifiltration is an alpha complex version of the core bifiltration which is smaller in size. Moreover, along the horizontal line k=1, the Delaunay core bifiltration is identical to the alpha complex.

Input:
  • points: The point cloud as an ArrayLike of shape (n, d) where n is the number of points and d is the dimension of the points.

  • beta: The beta parameter for the Delaunay Core Bifiltration (default 1.0).

  • ks: The list of k-values to include in the bifiltration (default None). If None, the k-values are set to [1, 2, …, n] where n is the number of points in the point cloud. For large point clouds, it is recommended to set ks to a smaller list of k-values to reduce computation time. The values in ks must all be integers, positive, and less than or equal to the number of points in the point cloud.

  • precision: The precision of the computation of the AlphaComplex, one of [‘safe’, ‘exact’, ‘fast’] (default ‘safe’). See the GUDHI documentation for more information.

  • verbose: Whether to print progress messages (default False).

  • max_alpha_square: The maximum squared alpha value to consider when createing the alpha complex (default inf). See the GUDHI documentation for more information.

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • beta (float)

  • ks (Sequence[int] | None)

  • precision (str)

  • verbose (bool)

  • max_alpha_square (float)

Return type:

SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64

multipers.filtrations.Cubical(image, **slicer_kwargs)

Computes the cubical filtration of an image. The last axis dimention is interpreted as the number of parameters.

Input:
  • image: ArrayLike of shape (*image_resolution, num_parameters)

  • ** args : specify non-default slicer parameters

Parameters:

image (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

multipers.filtrations.DegreeRips(*, points=None, distance_matrix=None, ks=None, threshold_radius=None)

The DegreeRips filtration.

multipers.filtrations.DelaunayCodensity(points, bandwidth=None, *, return_log=True, dtm_mass=None, kernel='gaussian', threshold_radius=None, reduce_degree=-1, vineyard=None, dtype=<class 'numpy.float64'>, verbose=False, clear=True, flagify=False)

TODO

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • bandwidth (float | None)

  • return_log (bool)

  • dtm_mass (float | None)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

  • threshold_radius (float | None)

  • reduce_degree (int)

  • vineyard (bool | None)

  • verbose (bool)

  • clear (bool)

  • flagify (bool)

multipers.filtrations.DelaunayLowerstar(points, function, *, distance_matrix=None, threshold_radius=None, reduce_degree=-1, vineyard=None, dtype=<class 'numpy.float64'>, verbose=False, clear=True, flagify=False)

Computes the Function Delaunay bifiltration. Similar to RipsLowerstar, but most suited for low-dimensional euclidean data. See [Delaunay bifiltrations of functions on point clouds, Alonso et al] https://doi.org/10.1137/1.9781611977912.173

Input:
  • points or distance_matrix: ArrayLike

  • function : ArrayLike of shape (num_data, )

  • threshold_radius: max edge length of the rips. Defaults at min(max(distance_matrix, axis=1)).

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • function (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • distance_matrix (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • threshold_radius (float | None)

  • reduce_degree (int)

  • vineyard (bool | None)

  • verbose (bool)

  • clear (bool)

  • flagify (bool)

multipers.filtrations.RipsCodensity(points, bandwidth=None, *, return_log=True, dtm_mass=None, kernel='gaussian', threshold_radius=None)

Computes the Rips density filtration.

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

  • bandwidth (float | None)

  • return_log (bool)

  • dtm_mass (float | None)

  • kernel (Literal['gaussian', 'exponential', 'exponential_kernel', 'multivariate_gaussian', 'sinc'] | ~collections.abc.Callable)

  • threshold_radius (float | None)

multipers.filtrations.RipsLowerstar(*, points=None, distance_matrix=None, function=None, threshold_radius=None)

Computes the Rips complex, with the usual rips filtration as a first parameter, and the lower star multi filtration as other parameter.

Input:
  • points or distance_matrix: ArrayLike

  • function : ArrayLike of shape (num_data, num_parameters -1)

  • threshold_radius: max edge length of the rips. Defaults at min(max(distance_matrix, axis=1)).

Parameters:
  • points (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • distance_matrix (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • function (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None)

  • threshold_radius (float | None)