ripser.Rips¶
- class ripser.Rips(maxdim=1, thresh=inf, coeff=2, do_cocycles=False, n_perm=None, verbose=True)[source]¶
sklearn style class interface for
ripser
withfit
andtransform
methods..- Parameters:
maxdim (int, optional, default 1) – Maximum homology dimension computed. Will compute all dimensions lower than and equal to this value. For 1, H_0 and H_1 will be computed.
thresh (float, default infinity) – Maximum distances considered when constructing filtration. If infinity, compute the entire filtration.
coeff (int prime, default 2) – Compute homology with coefficients in the prime field Z/pZ for p=coeff.
do_cocycles (bool) – Indicator of whether to compute cocycles, if so, we compute and store cocycles in the cocycles_ dictionary Rips member variable
n_perm (int) – The number of points to subsample in a “greedy permutation,” or a furthest point sampling of the points. These points will be used in lieu of the full point cloud for a faster computation, at the expense of some accuracy, which can be bounded as a maximum bottleneck distance to all diagrams on the original point set
verbose (boolean) – Whether to print out information about this object as it is constructed
- `dgm_`
After transform, dgm_ contains computed persistence diagrams in each dimension
- Type:
list of ndarray, each shape (n_pairs, 2)
- cocycles_¶
A list of representative cocycles in each dimension. The list in each dimension is parallel to the diagram in that dimension; that is, each entry of the list is a representative cocycle of the corresponding point expressed as an ndarray(K, d+1), where K is the number of nonzero values of the cocycle and d is the dimension of the cocycle. The first d columns of each array index into the simplices of the (subsampled) point cloud, and the last column is the value of the cocycle at that simplex
- Type:
list (size maxdim) of list of ndarray
- dperm2all_¶
The distance matrix used in the computation if n_perm is none. Otherwise, the distance from all points in the permutation to all points in the dataset
- Type:
ndarray(n_samples, n_samples) or ndarray (n_perm, n_samples) if n_perm
- metric_¶
The metric to use when calculating distance between instances in a feature array. If metric is a string, it must be one of the options specified in pairwise_distances, including “euclidean”, “manhattan”, or “cosine”. Alternatively, if metric is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two arrays from X as input and return a value indicating the distance between them.
- Type:
string or callable
- num_edges¶
The number of edges added during the computation
- Type:
int
- idx_perm¶
Index into the original point cloud of the points used as a subsample in the greedy permutation
- Type:
ndarray(n_perm) if n_perm > 0
- r_cover¶
Covering radius of the subsampled points. If n_perm <= 0, then the full point cloud was used and this is 0
- Type:
float
Examples
from ripser import Rips import tadasets data = tadasets.dsphere(n=110, d=2)[0] rips = Rips() rips.transform(data) rips.plot()
Methods
__init__
([maxdim, thresh, coeff, ...])fit_transform
(X[, distance_matrix, metric])Compute persistence diagrams for X data array and return the diagrams.
plot
([diagrams])A helper function to plot persistence diagrams.
set_output
(*[, transform])Set output container.
transform
(X[, distance_matrix, metric])