View source: R/step-ts-velocity.R
step_ts_velocity | R Documentation |
step_ts_velocity
creates a a specification of a recipe
step that will convert numeric data into from a time series into its
velocity.
step_ts_velocity(
recipe,
...,
role = "predictor",
trained = FALSE,
columns = NULL,
skip = FALSE,
id = rand_id("ts_velocity")
)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose which
variables that will be used to create the new variables. The
selected variables should have class |
role |
For model terms created by this step, what analysis role should they be assigned?. By default, the function assumes that the new variable columns created by the original variables will be used as predictors in a model. |
trained |
A logical to indicate if the quantities for preprocessing have been estimated. |
columns |
A character string of variables that will be
used as inputs. This field is a placeholder and will be
populated once |
skip |
A logical. Should the step be skipped when the recipe is baked by bake.recipe()? While all operations are baked when prep.recipe() is run, some operations may not be able to be conducted on new data (e.g. processing the outcome variable(s)). Care should be taken when using skip = TRUE as it may affect the computations for subsequent operations. |
id |
A character string that is unique to this step to identify it. |
Numeric Variables
Unlike other steps, step_ts_velocity
does not
remove the original numeric variables. recipes::step_rm()
can be
used for this purpose.
For step_ts_velocity
, an updated version of recipe with
the new step added to the sequence of existing steps (if any).
Main Recipe Functions:
recipes::recipe()
recipes::prep()
recipes::bake()
Other Recipes:
step_ts_acceleration()
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(recipes))
len_out = 10
by_unit = "month"
start_date = as.Date("2021-01-01")
data_tbl <- tibble(
date_col = seq.Date(from = start_date, length.out = len_out, by = by_unit),
a = rnorm(len_out),
b = runif(len_out)
)
# Create a recipe object
rec_obj <- recipe(a ~ ., data = data_tbl) %>%
step_ts_velocity(b)
# View the recipe object
rec_obj
# Prepare the recipe object
prep(rec_obj)
# Bake the recipe object - Adds the Time Series Signature
bake(prep(rec_obj), data_tbl)
rec_obj %>% prep() %>% juice()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.