step_hai_scale_zscore
creates a a specification of a recipe
step that will convert numeric data into from a time series into its
velocity.
Usage
step_hai_scale_zscore(
recipe,
...,
role = "predictor",
trained = FALSE,
columns = NULL,
skip = FALSE,
id = rand_id("hai_scale_zscore")
)
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
numeric
- 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
recipes::prep()
is used.- 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.
Value
For step_hai_scale_zscore
, an updated version of recipe with
the new step added to the sequence of existing steps (if any).
Main Recipe Functions:
Details
Numeric Variables
Unlike other steps, step_hai_scale_zscore
does not
remove the original numeric variables. recipes::step_rm()
can be
used for this purpose.
See also
Other Recipes:
step_hai_fourier()
,
step_hai_fourier_discrete()
,
step_hai_hyperbolic()
,
step_hai_scale_zero_one()
,
step_hai_winsorized_move()
,
step_hai_winsorized_truncate()
Other Scale:
hai_scale_zero_one_augment()
,
hai_scale_zero_one_vec()
,
hai_scale_zscore_augment()
,
hai_scale_zscore_vec()
Examples
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(recipes))
data_tbl <- data.frame(
a = mtcars$mpg,
b = AirPassengers %>% as.vector() %>% head(32)
)
# Create a recipe object
rec_obj <- recipe(a ~ ., data = data_tbl) %>%
step_hai_scale_zscore(b)
# View the recipe object
rec_obj
#>
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#>
#> ── Inputs
#> Number of variables by role
#> outcome: 1
#> predictor: 1
#>
#> ── Operations
#> • Zero-One Scale Transformation on: b
# Prepare the recipe object
prep(rec_obj)
#>
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#>
#> ── Inputs
#> Number of variables by role
#> outcome: 1
#> predictor: 1
#>
#> ── Training information
#> Training data contained 32 data points and no incomplete rows.
#>
#> ── Operations
#> • Zero-One Scale Transformation on: b | Trained
# Bake the recipe object - Adds the Time Series Signature
bake(prep(rec_obj), data_tbl)
#> # A tibble: 32 × 3
#> b a hai_scale_zscore_b
#> <dbl> <dbl> <dbl>
#> 1 112 21 -1.24
#> 2 118 21 -1.00
#> 3 132 22.8 -0.444
#> 4 129 21.4 -0.564
#> 5 121 18.7 -0.884
#> 6 135 18.1 -0.325
#> 7 148 14.3 0.195
#> 8 148 24.4 0.195
#> 9 136 22.8 -0.285
#> 10 119 19.2 -0.964
#> # ℹ 22 more rows
rec_obj %>%
prep() %>%
juice()
#> # A tibble: 32 × 3
#> b a hai_scale_zscore_b
#> <dbl> <dbl> <dbl>
#> 1 112 21 -1.24
#> 2 118 21 -1.00
#> 3 132 22.8 -0.444
#> 4 129 21.4 -0.564
#> 5 121 18.7 -0.884
#> 6 135 18.1 -0.325
#> 7 148 14.3 0.195
#> 8 148 24.4 0.195
#> 9 136 22.8 -0.285
#> 10 119 19.2 -0.964
#> # ℹ 22 more rows