step_basis()
is a single function that creates a specification of a recipe
step that will create new columns that are basis expansions, using any of the
basis expansion functions in this package.
Usage
step_basis(
recipe,
...,
role = NA,
trained = FALSE,
fn = NULL,
options = list(),
object = NULL,
prefix = deparse(substitute(fn)),
skip = FALSE,
id = recipes::rand_id("basis")
)
Arguments
- recipe
A recipe object.
- ...
One or more selector functions to choose variables for this step. See
recipes::selections()
for more details.- role
For model terms created by this step, what analysis role should they be assigned? By default, the new columns created by this step from the original variables will be used as predictors in a model.
- trained
A logical to indicate if the quantities for preprocessing have been estimated.
- fn
The basis function to use, e.g.,
b_rff()
.- options
A list of options for the basis function
fn
.- object
The basis object created once the step has been trained.
- prefix
The prefix to use for the new column names. Numbers will be appended, per
recipes::names0()
, to create column names.- skip
A logical. Should the step be skipped when the recipe is baked by
recipes::bake()
?- id
A character string that is unique to this step to identify it.
Value
An updated version of recipe with the new step added to the sequence of any existing operations.
Examples
rec = recipes::recipe(depth ~ lat + long + mag, quakes)
rec_rff = step_basis(rec, lat, long, fn = b_rff,
options = list(p = 5, kernel = k_rbf(2), stdize="none"))
recipes::bake(recipes::prep(rec_rff), new_data=NULL)
#> # A tibble: 1,000 × 7
#> mag depth b_rff1 b_rff2 b_rff3 b_rff4 b_rff5
#> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 4.8 562 -0.361 0.121 -0.302 0.351 -0.0812
#> 2 4.2 650 -0.297 0.111 -0.428 0.370 -0.178
#> 3 5.4 42 0.404 -0.331 0.428 -0.398 -0.175
#> 4 4.1 626 -0.390 -0.397 -0.260 0.423 0.411
#> 5 4 649 -0.379 0.154 -0.189 0.325 -0.0512
#> 6 4 195 -0.431 0.203 0.444 0.218 0.307
#> 7 4.8 82 -0.438 -0.425 -0.441 0.349 0.446
#> 8 4.4 194 0.249 -0.447 -0.299 -0.318 0.414
#> 9 4.7 211 0.115 -0.432 -0.357 -0.245 0.447
#> 10 4.3 622 -0.425 -0.430 -0.285 0.212 0.383
#> # ℹ 990 more rows