Questions tagged [r-recipes]

recipes is an R package by Max Kuhn and Hadley Wickham for creating and preprocessing design matrices.

recipes is an R package by Max Kuhn and Hadley Wickham for creating and preprocessing design matrices.

131 questions
0
votes
1 answer

Column name being duplicated in recipe

This is the piece of code i'm having troubles with: pump_recipe <- recipe(status_group ~ ., data = data) %>% step_impute_median(all_numeric_predictors()) %>% step_impute_knn(all_nominal_predictors()) %>% step_dummy(all_nominal_predictors())…
Norhther
  • 545
  • 3
  • 15
  • 35
0
votes
1 answer

how to unlist a `tknlist`?

step_tokenize returns a vector of type tknlist. How can I get a rectangular for of it? I mean something like unnesting the tokens and add them a cols of the tibble. library(textrecipes) library(modeldata) data(tate_text) tate_rec <- recipe(~., data…
Nip
  • 387
  • 4
  • 11
0
votes
1 answer

tidymodels recipes: can I use step_dummy() to one-hot encode the categorical variabes *except* booleans which only needs 1 dummy?

If a categorical variable has more than 2 values (like marital status= single/married/widowed/separated/divorced), then I need to create N dummies, one for each of the possible levels. This is done using step_dummy(one_hot = TRUE). However, if the …
Zoltan
  • 760
  • 4
  • 15
0
votes
0 answers

How to reverse factor levels for step_woe preprocessing recipe step

I am applying WOE (weight of evidence) transformation for my features (using 'step_woe' from the 'embed' package) within the 'recipes' framework, but by default it takes the 0 value as reference and thus the WOE values are reversed. I am trying to…
0
votes
2 answers

How to prep a recipe, including tunable arguments?

As you can see from my code, I am trying to include feature selection into my tidymodels workflow. I am using some kaggle data, trying to predict customer churn. In order to apply processing to test and training data, I am baking the recipe after I…
Leonhard Geisler
  • 506
  • 3
  • 15
0
votes
1 answer

How to mutate a list-column using purrr::map() to store a "recipe" object created via recipe()?

I'm trying to use dplyr::mutate() in combination with purrr::map() to create a "recipe" object with recipes::recipe(). If I do it out of tibble context this works fine: library(rsample) library(recipe) iris_split <- initial_split(iris, prop =…
Emman
  • 3,695
  • 2
  • 20
  • 44
0
votes
1 answer

Does Tidymodel's Recipes provide functions to manipulate logical variables?

I am looking through the documentation on Recipes and I find step_string2factor and step_num2factor but I can find no equivalent step_logical2factor. I'm building a classification model and need to convert my T/F outcome to a factor. Does that have…
jntrcs
  • 527
  • 1
  • 5
  • 13
0
votes
0 answers

recipe step_mutate for NA dates is messing the non-NA

preparing recipe for training tidymodels I want to mutate when NA but is messing with the rest of dates library(tidyverse) df <- tibble(target = c(0, 1), date1= c(lubridate::ymd("2020-08-05"),NA)) …
Forge
  • 1,587
  • 1
  • 15
  • 36
0
votes
1 answer

Error in tune_grid with no applicable method for prep R tidymodels

I use a custom step function that I have built for a package of mine that works just fine, it is in a local copy of the package (Not yet submitted to CRAN) link to function here: step_hai_fourier Here is the session info (we can see healthyR.ai…
MCP_infiltrator
  • 3,961
  • 10
  • 45
  • 82
0
votes
0 answers

Is there a function to retrieve the role of a variable in a 'recipe'?

In recipe, you can specify the roles variables will have by passing a character string that specifies roles such "outcome", "predictor", "case_weight", "ID", etc. For example, the iris dataset variables have the following roles: > recipe(Species ~…
Zweifler
  • 375
  • 1
  • 4
  • 12
0
votes
2 answers

Calculated Column Based on Rows in Tidymodels Recipe

I have a dataframe as follows: ID Col1 RespID Col3 Col4 1 blue 729Ad 3.2 A 2 orange 295gS 6.5 A 3 red 729Ad 8.4 B 4 yellow 592Jd 2.9 A 5 green 937sa 3.5 B I would like to calculate a new column, Col5, such that its value is 1 if…
piper180
  • 329
  • 2
  • 12
0
votes
2 answers

step_mutate() couldn't find the function str_remove()

I have a recipe with the step_mutate() function in between, performing text data transformations on titanic dataset, supported by the stringr package. library(tidyverse) library(tidymodels) extract_title <- function(x)…
dzegpi
  • 554
  • 5
  • 14
0
votes
1 answer

How to add a step to remove a column with constant value?

Background: I'm creating a recipe to clean and transform time-series data that will be used by multiple models. One of the steps in the recipe is to remove correlated predictors using the step_corr() function. However, due to the nature of the data…
fahmy
  • 3,543
  • 31
  • 47
0
votes
1 answer

Error in UseMethod("required_pkgs") : no applicable method for 'required_pkgs' applied to an object of class "workflow"

I'm following Jan Kirenz tutorial for classification using Tidymodels. Everything so far has gone well until I try to evaluate the model using the function fit_resamples(). I keep getting the error message Error in UseMethod("required_pkgs") : no…
0
votes
1 answer

How to convert normalized numeric variable (library(recipes)) back to original value in R

I normalized the numeric variables by library(recipes) in R before putting into Decision Tree models to predict outcome. Now, I have decision tree, and age is one of important variables in the node, like >1.5 and < 1.5. I want to convert that -1.5…
1 2 3
8 9