Vector Representation: Persistence Image
Source:R/representation-vector-methods.R
PersistenceImage.RdComputes persistence images from a list of persistence diagrams. A persistence image is a 2D function computed from a persistence diagram by convolving the diagram points with a weighted Gaussian kernel. The plane is then discretized into an image with pixels, which is flattened and returned as a vector. See http://jmlr.org/papers/v18/16-337.html for more details.
Super classes
rgudhi::PythonClass -> rgudhi::SKLearnClass -> rgudhi::VectorRepresentationStep -> PersistenceImage
Methods
Method new()
The PersistenceImage constructor.
Usage
PersistenceImage$new(
bandwidth = 1,
weight = function(x) 1,
resolution = c(20, 20),
im_range = rep(NA_real_, 4)
)Arguments
bandwidthA numeric value specifying the bandwidth of the Gaussian kernel. Defaults to
1.0.weightA 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]\).resolutionAn length-1 integer vector specifying the size (in pixels) of the persistence image. Defaults to
rep(20L, 2).im_rangeA length-4 numeric vector specifying the two-dimensional domain for the persistence image, of the form \([x_{\min}, y_{\min}, x_{\max}, y_{\max}]\). Defaults to
rep(NA, 4). If one of the values isNA, it can be computed from the persistence diagrams with the$fit()method.
Method apply()
Applies the PersistenceImage class on a single persistence
diagram and outputs the result.
Arguments
diagA 3-column tibble::tibble specifying a persistence diagram.
Returns
A tibble::tibble storing the persistence image 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)
pei <- PersistenceImage$new()
pei$apply(dgm)
pei$fit_transform(list(dgm))
}