step_timeseries_signature creates a a specification of a recipe
step that will convert date or date-time data into many
features that can aid in machine learning with time-series data
step_timeseries_signature( recipe, ..., role = "predictor", trained = FALSE, columns = NULL, skip = FALSE, id = rand_id("timeseries_signature") ) ## S3 method for class 'step_timeseries_signature' tidy(x, ...)
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
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.
A logical to indicate if the quantities for preprocessing have been estimated.
A character string of variables that will be
used as inputs. This field is a placeholder and will be
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.
A character string that is unique to this step to identify it.
Unlike other steps,
step_timeseries_signature does not
remove the original date variables.
recipes::step_rm() can be
used for this purpose.
index.num feature created has a large magnitude (number of seconds since 1970-01-01).
It's a good idea to scale and center this feature (e.g. use
Removing Unnecessary Features
By default, many features are created automatically. Unnecessary features can
be removed using
step_timeseries_signature, an updated version of recipe with
the new step added to the sequence of existing steps (if any).
tidy method, a tibble with columns
(the selectors or variables selected),
value (the feature
Time Series Analysis:
Diffs & Lags
Main Recipe Functions:
library(recipes) library(tidyverse) library(tidyquant) library(timetk) FB_tbl <- FANG %>% filter(symbol == "FB") # Create a recipe object with a timeseries signature step rec_obj <- recipe(adjusted ~ ., data = FB_tbl) %>% step_timeseries_signature(date) # 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), FB_tbl) # Tidy shows which features have been added during the 1st step # in this case, step 1 is the step_timeseries_signature step tidy(rec_obj) tidy(rec_obj, number = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.