step_timeseries_signature: Time Series Feature (Signature) Generator

View source: R/recipes-step_timeseries_signature.R

step_timeseries_signatureR Documentation

Time Series Feature (Signature) Generator


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


  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 Date or POSIXct. See recipes::selections() for more details. For the tidy method, these are not currently used.


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 populated once recipes::prep() is used.


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.


A step_timeseries_signature object.


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().


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()



FB_tbl <- FANG %>% dplyr::filter(symbol == "FB")

# Create a recipe object with a timeseries signature step
rec_obj <- recipe(adjusted ~ ., data = FB_tbl) %>%

# View the recipe object

# Prepare the recipe object

# 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, number = 1)

timetk documentation built on Nov. 2, 2023, 6:18 p.m.