step_textfeature()
creates a specification of a recipe step that will
extract a number of numeric features of a text column.
Usage
step_textfeature(
recipe,
...,
role = "predictor",
trained = FALSE,
columns = NULL,
extract_functions = count_functions,
prefix = "textfeature",
keep_original_cols = FALSE,
skip = FALSE,
id = rand_id("textfeature")
)
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 are affected by the 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 function assumes that the new 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 variable names that will be populated (eventually) by the
terms
argument. This isNULL
until the step is trained byrecipes::prep.recipe()
.- extract_functions
A named list of feature extracting functions. Defaults to
count_functions
. See details for more information.- prefix
A prefix for generated column names, defaults to "textfeature".
- keep_original_cols
A logical to keep the original variables in the output. Defaults to
FALSE
.- skip
A logical. Should the step be skipped when the recipe is baked by
recipes::bake.recipe()
? While all operations are baked whenrecipes::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 usingskip = FALSE
.- 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 existing steps (if any).
Details
This step will take a character column and returns a number of numeric
columns equal to the number of functions in the list passed to the
extract_functions
argument.
All the functions passed to extract_functions
must take a character vector
as input and return a numeric vector of the same length, otherwise an error
will be thrown.
Tidying
When you tidy()
this step, a tibble is returned with
columns terms
, functions
, and id
:
- terms
character, the selectors or variables selected
- functions
character, name of feature functions
- id
character, id of this step
See also
Other Steps for Numeric Variables From Characters:
step_dummy_hash()
,
step_sequence_onehot()
Examples
library(recipes)
library(modeldata)
data(tate_text)
tate_rec <- recipe(~., data = tate_text) %>%
step_textfeature(medium)
tate_obj <- tate_rec %>%
prep()
bake(tate_obj, new_data = NULL) %>%
slice(1:2)
#> # A tibble: 2 × 30
#> id artist title year textfeature_medium_n…¹ textfeature_medium_n…²
#> <dbl> <fct> <fct> <dbl> <int> <int>
#> 1 21926 Absalon Prop… 1990 8 8
#> 2 20472 Auerbac… Mich… 1990 3 3
#> # ℹ abbreviated names: ¹textfeature_medium_n_words,
#> # ²textfeature_medium_n_uq_words
#> # ℹ 24 more variables: textfeature_medium_n_charS <int>,
#> # textfeature_medium_n_uq_charS <int>,
#> # textfeature_medium_n_digits <int>,
#> # textfeature_medium_n_hashtags <int>,
#> # textfeature_medium_n_uq_hashtags <int>, …
bake(tate_obj, new_data = NULL) %>%
pull(textfeature_medium_n_words)
#> [1] 8 3 3 3 4 4 4 3 6 3 3 3 3 3 3 3 6 7 10 4 4 3
#> [23] 3 3 3 3 3 3 3 5 8 4 4 3 3 3 3 3 3 1 5 4 1 10
#> [45] 3 3 3 3 3 3 3 3 3 5 10 5 6 7 4 4 4 4 7 3 3 3
#> [67] 3 4 3 6 3 3 3 5 11 3 3 4 18 3 8 6 10 13 5 3 4 3
#> [89] 3 3 3 3 3 3 3 4 3 3 3 3 5 3 5 3 3 3 4 5 6 3
#> [111] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
#> [133] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
#> [155] 3 3 3 3 3 6 3 6 6 1 5 8 1 4 6 6 6 4 8 5 3 3
#> [177] 3 3 7 3 3 3 3 6 3 3 6 4 8 11 4 11 3 3 4 3 6 6
#> [199] 3 3 6 3 6 8 7 5 6 3 6 5 5 3 5 5 3 3 3 3 3 3
#> [221] 7 7 7 7 7 7 7 7 5 5 3 3 3 3 3 3 3 3 3 3 19 6
#> [243] 3 3 3 6 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 3
#> [265] 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5
#> [287] 5 5 5 3 6 7 7 6 6 4 4 4 4 4 4 4 4 6 6 10 3 3
#> [309] 4 4 7 3 3 6 1 14 14 11 9 6 9 4 11 4 14 3 6 6 4 4
#> [331] 4 4 6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5 4 4 7 4 4 11 6 10 7 4 6 4 4 4 4
#> [3455] 4 4 5 3 4 6 15 7 3 3 4 10 4 3 3 3 3 4 5 5 5 1
#> [3477] 6 3 4 6 7 4 4 6 6 6 6 5 3 19 13 2 11 6 6 3 10 10
#> [3499] 2 3 3 3 5 5 5 5 20 5 8 9 16 3 3 3 6 3 3 3 3 3
#> [3521] 3 8 10 7 20 14 4 4 4 16 8 10 16 9 4 7 7 7 7 1 11 11
#> [3543] 7 3 3 3 4 5 4 4 15 15 15 15 8 8 13 1 5 8 8 8 8 6
#> [3565] 6 6 6 6 6 6 4 4 4 2 3 6 8 5 6 6 8 9 7 2 2 2
#> [3587] 4 3 4 6 10 6 6 6 6 5 10 7 14 11 11 3 5 8 4 16 8 19
#> [3609] 8 8 5 4 5 5 6 5 5 5 7 6 4 6 6 6 6 6 6 6 11 6
#> [3631] 5 5 6 4 4 6 11 4 6 5 5 5 5 5 5 8 4 4 4 4 4 4
#> [3653] 4 4 6 3 2 5 18 17 18 6 8 8 3 3 4 3 3 4 6 6 17 8
#> [3675] 5 7 6 8 13 10 4 6 6 6 8 10 8 4 4 4 4 4 4 8 8 5
#> [3697] 6 9 9 9 5 8 8 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
#> [3719] 19 5 8 11 4 3 3 11 4 9 9 4 7 11 4 8 4 8 5 6 6 6
#> [3741] 6 6 6 6 6 3 3 7 5 5 5 5 4 1 8 4 4 4 4 4 4 11
#> [3763] 5 4 4 4 4 4 4 4 3 12 8 8 6 11 4 14 3 3 12 4 6 3
#> [3785] 13 3 3 5 8 12 4 4 19 4 4 4 4 4 4 8 8 4 5 5 6 3
#> [3807] 6 6 6 6 5 5 4 6 4 4 7 6 7 4 9 7 7 7 7 7 7 7
#> [3829] 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 5 6 6 6 6 6
#> [3851] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
#> [3873] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
#> [3895] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
#> [3917] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
#> [3939] 6 6 6 6 6 6 6 6 6 4 4 4 3 3 3 4 1 3 3 3 6 6
#> [3961] 6 10 9 3 4 3 11 4 8 3 3 3 3 3 3 3 5 2 7 8 3 6
#> [3983] 6 3 3 8 6 7 4 7 7 7 15 7 5 7 3 5 3 6 7 4 4 4
#> [4005] 4 4 4 4 4 8 7 7 9 8 5 4 3 6 7 4 9 4 4 3 10 3
#> [4027] 4 7 3 3 3 7 4 5 3 10 5 7 6 3 3 4 4 4 4 4 5 4
#> [4049] 4 4 6 10 3 6 16 3 15 6 7 4 6 19 4 10 6 3 8 11 3 9
#> [4071] 12 8 17 4 5 6 6 6 5 5 5 7 5 1 6 11 14 9 6 6 3 7
#> [4093] 6 5 7 7 3 3 4 6 3 3 3 3 3 3 3 5 1 6 12 11 3 4
#> [4115] 8 11 9 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
#> [4137] 4 4 4 4 4 4 4 4 10 7 1 7 4 3 3 3 3 5 7 4 6 6
#> [4159] 6 6 6 6 6 6 6 6 4 3 3 5 3 3 3 16 11 3 17 5 5 5
#> [4181] 4 4 4 4 4 10 4 9 9 9 4 5 4 4 8 9 4 1 4 5 5 5
#> [4203] 6 5 5 4 8 10 12 4 9 15 3 4 4 4 4 3 1 3 8 8 8 8
#> [4225] 8 3 3 3 4 4 6 3 3 3 4 3 3 3 9 14 3 1 7 6 6 6
#> [4247] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
#> [4269] 6 6 6 6 7 6 6 6 6 6 6 6 6 6 6 4
tidy(tate_rec, number = 1)
#> # A tibble: 1 × 3
#> terms functions id
#> <chr> <chr> <chr>
#> 1 medium NA textfeature_JMWzA
tidy(tate_obj, number = 1)
#> # A tibble: 26 × 3
#> terms functions id
#> <chr> <chr> <chr>
#> 1 medium n_words textfeature_JMWzA
#> 2 medium n_uq_words textfeature_JMWzA
#> 3 medium n_charS textfeature_JMWzA
#> 4 medium n_uq_charS textfeature_JMWzA
#> 5 medium n_digits textfeature_JMWzA
#> 6 medium n_hashtags textfeature_JMWzA
#> 7 medium n_uq_hashtags textfeature_JMWzA
#> 8 medium n_mentions textfeature_JMWzA
#> 9 medium n_uq_mentions textfeature_JMWzA
#> 10 medium n_commas textfeature_JMWzA
#> # ℹ 16 more rows
# Using custom extraction functions
nchar_round_10 <- function(x) round(nchar(x) / 10) * 10
recipe(~., data = tate_text) %>%
step_textfeature(medium,
extract_functions = list(nchar10 = nchar_round_10)
) %>%
prep() %>%
bake(new_data = NULL)
#> # A tibble: 4,284 × 5
#> id artist title year textfeature_medium_n…¹
#> <dbl> <fct> <fct> <dbl> <dbl>
#> 1 21926 Absalon Proposals for a… 1990 60
#> 2 20472 Auerbach, Frank Michael 1990 20
#> 3 20474 Auerbach, Frank Geoffrey 1990 20
#> 4 20473 Auerbach, Frank Jake 1990 20
#> 5 20513 Auerbach, Frank To the Studios 1990 20
#> 6 21389 Ayres, OBE Gillian Phaëthon 1990 20
#> 7 121187 Barlow, Phyllida Untitled 1990 20
#> 8 19455 Baselitz, Georg Green VIII 1990 20
#> 9 20938 Beattie, Basil Present Bound 1990 30
#> 10 105941 Beuys, Joseph Joseph Beuys: A… 1990 10
#> # ℹ 4,274 more rows
#> # ℹ abbreviated name: ¹textfeature_medium_nchar10