View source: R/gap_derivative.R
| step_gap_derivative | R Documentation |
step_gap_derivative() creates a specification of a recipe step that
computes the gap-segment (Norris-Williams) derivative of the spectra with
gap_derivative().
step_gap_derivative(
recipe,
...,
derivative = 1,
gap = 5,
segment = 3,
segments = TRUE,
role = NA,
trained = FALSE,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("gap_derivative")
)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose the predictors (for
example, the spectral channels). See |
derivative |
The derivative: 1 (default) or 2. |
gap |
The number of channels between two segments, an odd number. Default is 5. |
segment |
The number of channels averaged in each segment, an odd number. Default is 3. |
segments |
A logical: filter the segments between gaps of the
wavelength axis separately ( |
role |
Not used by this step, since no new variables are created. |
trained |
A logical indicating whether the step has been trained. |
columns |
The names of the selected columns, stored once the step has been trained. |
skip |
A logical. Should the step be skipped when the recipe is baked
by |
id |
A character string that is unique to this step. |
The selected columns form one spectrum per row, and are replaced by their
derivative. Nothing is estimated from the training data. The derivative,
gap and segment can be tuned with tune::tune() (dials parameters
savgol_derivative(), with values 1 and 2, and window_size()); an even
gap or segment, as a tuning grid may propose, is increased to the next
odd number. tidy() returns the terms,
derivative, gap, segment and id.
An updated version of recipe with the new step added to the
sequence of existing steps.
gap_derivative(), step_savgol(), step_bin_spectra()
if (rlang::is_installed("recipes")) {
data(forageLIBS)
rec <- recipes::recipe(K ~ ., data = forageLIBS[-c(1:10, 12:14)]) |>
step_gap_derivative(recipes::all_predictors(), gap = 5, segment = 3) |>
recipes::prep()
recipes::tidy(rec, number = 1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.