step_vpd_persistence_landscape {tdarec} | R Documentation |
Persistence Landscape Vectorization of Persistent Homology
Description
The function step_vpd_persistence_landscape()
creates
a specification of a recipe step that will convert
a list-column of 3-column matrices of persistence data
to a list-column of 1-row matrices of vectorizations.
Usage
step_vpd_persistence_landscape(
recipe,
...,
role = "predictor",
trained = FALSE,
hom_degree = 0L,
xseq = NULL,
xmin = NULL,
xmax = NULL,
xlen = NULL,
xby = NULL,
num_levels = 6L,
generalized = FALSE,
weight_func_pl = "triangle",
bandwidth = NULL,
columns = NULL,
keep_original_cols = TRUE,
skip = FALSE,
id = rand_id("vpd_persistence_landscape")
)
Arguments
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose variables for this step.
See |
role |
For model terms created by this step, what analysis role should they be assigned? By default, the new columns created by this step from the original variables will be used as predictors in a model. |
trained |
A logical to indicate if the quantities for preprocessing have been estimated. |
hom_degree |
The homological degree of the features to be transformed. |
xseq |
A discretization grid, as an increasing numeric vector.
|
xmin , xmax , xlen , xby |
Limits and resolution of a discretization grid;
specify only one of |
num_levels |
The number of levels of a persistence landscape to vectorize.
If |
generalized |
Logical indicator to compute generalized functions. |
weight_func_pl |
A single character for the type of kernel function used to compute generalized landscapes. |
bandwidth |
The bandwidth of a kernel function. |
columns |
A character string of the selected variable names. This field
is a placeholder and will be populated once |
keep_original_cols |
A logical to keep the original variables in the
output. Defaults to |
skip |
A logical. Should the step be skipped when the recipe is baked by
|
id |
A character string that is unique to this step to identify it. |
Details
Persistent homology is usually encoded as birth–death pairs (barcodes or diagrams), but the space of persistence data sets does not satisfy convenient statistical properties. Such applications as hypothesis testing and machine learning benefit from transformations of persistence data, often to Hilbert spaces (vector spaces with inner products and induced metrics).
Value
An updated version of recipe
with the new step added to the
sequence of any existing operations.
Engine
The persistence landscape vectorization deploys
TDAvec::computePersistenceLandscape()
.
See there for definitions and references.
Tuning Parameters
This step has 4 tuning parameters:
-
hom_degree
: Homological degree (type: integer, default:0L
) -
num_levels
: # Levels or envelopes (type: integer, default:6L
) -
weight_func_pl
: Kernel distance weight function (type: character, default:"triangle"
) -
bandwidth
: Kernel bandwidth (type: double, default:NULL
)
Examples
library(recipes)
# inspect vectorized features
volc_dat <- data.frame(image = I(list(volcano / 10)))
recipe(~ image, data = volc_dat) %>%
step_pd_raster(image, method = "link_join") %>%
step_vpd_persistence_landscape(image, hom_degree = 1, num_levels = 3) %>%
print() -> volc_rec
print(volc_rec)
volc_rec %>%
prep(training = volc_dat) %>%
bake(new_data = volc_dat)
# dimension-reduce using vectorized features
data(permeability_qsar, package = "modeldata")
permeability_qsar %>%
transform(perm_cut = cut(permeability, breaks = seq(0, 60, 10))) %>%
subset(select = -permeability) %>%
tidyr::nest(chem_fp = -perm_cut) %>%
print() -> perm_dat
recipe(perm_cut ~ chem_fp, data = perm_dat) %>%
step_pd_point_cloud(chem_fp, max_hom_degree = 2) %>%
step_vpd_persistence_landscape(chem_fp, hom_degree = 1, num_levels = 3) %>%
step_pca(starts_with("chem_fp_"), num_comp = 2) %>%
print() -> perm_rec
perm_est <- prep(perm_rec, training = perm_dat)
perm_res <- bake(perm_est, new_data = perm_dat)
# inspect results
tidy(perm_rec)
tidy(perm_rec, number = 2)
tidy(perm_est, number = 2)
# visualize results
with(perm_res, {
plot(PC1, PC2, type = "n", asp = 1)
text(PC1, PC2, labels = perm_cut)
})