step_timeseries_signature {timetk} | R Documentation |
Time Series Feature (Signature) Generator
Description
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
Usage
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, ...)
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 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. |
x |
A |
Details
Date Variable
Unlike other steps, step_timeseries_signature
does not
remove the original date variables. recipes::step_rm()
can be
used for this purpose.
Scaling index.num
The 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 recipes::step_normalize()
).
Removing Unnecessary Features
By default, many features are created automatically. Unnecessary features can
be removed using recipes::step_rm()
.
Value
For step_timeseries_signature
, an updated version of recipe with
the new step added to the sequence of existing steps (if any).
For the tidy
method, a tibble with columns terms
(the selectors or variables selected), value
(the feature
names).
See Also
Time Series Analysis:
Engineered Features:
step_timeseries_signature()
,step_holiday_signature()
,step_fourier()
Diffs & Lags
step_diff()
,recipes::step_lag()
Smoothing:
step_slidify()
,step_smooth()
Variance Reduction:
step_box_cox()
Imputation:
step_ts_impute()
,step_ts_clean()
Padding:
step_ts_pad()
Main Recipe Functions:
-
recipes::recipe()
-
recipes::prep()
-
recipes::bake()
Examples
library(recipes)
library(dplyr)
FB_tbl <- FANG %>% dplyr::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)