Computes persistence silhouettes from a list of persistence diagrams. A persistence silhouette is computed by taking a weighted average of the collection of 1D piecewise-linear functions given by the persistence landscapes, and then by evenly sampling this average on a given range. Finally, the corresponding vector of samples is returned. See https://arxiv.org/abs/1312.0308 for more details.
Super classes
rgudhi::PythonClass
-> rgudhi::SKLearnClass
-> rgudhi::VectorRepresentationStep
-> Silhouette
Methods
Method new()
The Silhouette
constructor.
Usage
Silhouette$new(
weight = function(x) 1,
resolution = 100,
sample_range = rep(NA_real_, 2)
)
Arguments
weight
A function or a formula coercible into a function via
rlang::as_function()
specifying the weight function for the persistence diagram points. Defaults to the constant function~ 1
. This function must be defined on 2D points, i.e. lists or arrays of the form \([p_x,p_y]\).resolution
An length-1 integer vector specifying the size (in pixels) of the persistence image. Defaults to
rep(20L, 2)
.sample_range
A length-2 numeric vector specifying the domain for the entropy summary function, of the form \([x_{\min}, x_{\max}]\). Defaults to
rep(NA, 2)
. It is the interval on which samples will be drawn evenly. If one of the values isNA
, it can be computed from the persistence diagrams with the$fit()
method.
Method apply()
Applies the Silhouette
class on a single persistence
diagram and outputs the result.
Arguments
diag
A 2-column tibble::tibble specifying a persistence diagram.
Returns
A tibble::tibble storing the silhouette representation of the persistence diagram in a table suitable for visualization.
Examples
if (FALSE) { # reticulate::py_module_available("gudhi")
X <- seq_circle(10)
ac <- AlphaComplex$new(points = X)
st <- ac$create_simplex_tree()
dgm <- st$compute_persistence()$persistence_intervals_in_dimension(0)
ds <- DiagramSelector$new(use = TRUE)
dgm <- ds$apply(dgm)
sil <- Silhouette$new()
sil$apply(dgm) # TO DO: fix gd because it does not set sample_range automatically
sil$fit_transform(list(dgm))
}