step_pd_degree {tdarec} | R Documentation |
Separate persistent pairs by homological degree
Description
The function step_pd_degree()
creates a specification of a
recipe step that will separate data sets of persistent pairs by homological
degree. The input and output must be list-columns.
Usage
step_pd_degree(
recipe,
...,
role = NA_character_,
trained = FALSE,
hom_degrees = NULL,
columns = NULL,
keep_original_cols = FALSE,
skip = FALSE,
id = rand_id("pd_degree")
)
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_degrees |
Integer vector of homological degrees. |
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
The hom_degrees
argument sets the homological degrees for which to
return new list-columns. If not NULL
(the default), it is intersected
with the degrees found in any specified columns of the training data;
otherwise all found degrees are used. This parameter cannot be tuned.
Value
An updated version of recipe
with the new step added to the
sequence of any existing operations.
See Also
Other topological feature extraction via persistent homology:
step_pd_point_cloud()
,
step_pd_raster()
Examples
dat <- data.frame(
roads = I(list(eurodist, UScitiesD * 1.6)),
topos = I(list(volcano, 255 - volcano))
)
ph_rec <- recipe(~ ., data = dat) %>%
step_pd_point_cloud(roads) %>%
step_pd_raster(topos) %>%
step_pd_degree(roads, topos)
ph_prep <- prep(ph_rec, training = dat)
(ph_res <- bake(ph_prep, dat))
tidy(ph_rec, number = 3)
tidy(ph_prep, number = 3)
with_degs <- recipe(~ ., data = dat) %>%
step_pd_point_cloud(roads) %>%
step_pd_raster(topos) %>%
step_pd_degree(roads, topos, hom_degrees = c(1, 2))
with_degs <- prep(with_degs, training = dat)
bake(with_degs, dat)