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
2
votes
1 answer

Tidymodels recipes - add a step that just applies a feature engineering function?

A lot of feature engineering steps are transforms that do not need to be 'trained' on a dataset, for example, creating a new column x2 as x2=2*x1. These 'static transforms' are different are 'trainable' transforms such as demean and rescale. Instead…
2
votes
1 answer

How to de-normalize data with tidy-models in r

With tidymodels as the new workflow for developing models in R, how do I denormalize/Invert Power transformation data using tidymodels. dd <- data.frame(x1=1:5,x2 = 11:15,y=6:10). Now using the tidy model framework: model_recipe <- recipe(y ~ .,…
Azam Yahya
  • 646
  • 1
  • 7
  • 10
2
votes
0 answers

add a series of steps to end of recipe in r

The goal is to be able to add a series of new steps in sequence to the end of a recipe where the new steps are passed as arguments to a function. I can do what I want with a for…
Giovanni Colitti
  • 1,982
  • 11
  • 24
2
votes
1 answer

Why does an "id variable" in tidymodels/recipes play a predictor role?

This is the same issue as Predict with step_naomit and retain ID using tidymodels , but even though there is an accepted answer, the OP's last comment states the issue the "id variable" is being used as a predictor, as can be seen when looking at…
ap53
  • 783
  • 2
  • 8
  • 19
2
votes
1 answer

How to apply update_role (or a step) function from recipes to multiple columns

I'm using the recipes package from tidymodels. I'm trying to update_role for a few columns at the same time. Example: library(recipes) library(dplyr) cols_to_update = list() cols_to_update[["a"]] <- c("mpg", "cyl") mtcars %>% recipe() %>% …
mihagazvoda
  • 1,057
  • 13
  • 23
2
votes
1 answer

Using caret with recipes is leading to difficulties with resample

I've been using recipes to pipe into caret::train, which has been going well, but now I've tried some step_transforms, I'm getting the error: Error in resamples.default(model_list) : There are different numbers of resamples in each model when I…
Isaiah
  • 2,091
  • 3
  • 19
  • 28
2
votes
3 answers

How to use recipes package to replace missing values with a constant

I can't figure out how to use the recipes package to replace missing numeric variables with a constant. I did think about using step_lowerimpute, but I don't think I will be able to use it for my case. step_lowerimpute replaces missing values below…
1
vote
1 answer

Error in `step_log()`: When trying to make predictions with my model

I'm trying to make predictions with my testing data using my finalized workflow. But whenever I try using the predict function, it gives me this error: Error in `step_log()`: ! The following required column is missing from `new_data` in step…
Chelsea Lu
  • 11
  • 1
1
vote
2 answers

Use custom distance in step_umap function (tidymodels)

I'm trying to create a recipe (preprocess for Xgboost model) which will use a custom metric (dice). Here is my code : Dice function and distance matrix dice <- function(x,y){ n1 <- sum(x==1 & y==0); n2 <- sum(x==0 & y==1) n3 <- sum(x==1 & y==1) …
Benco016
  • 91
  • 1
  • 5
1
vote
2 answers

How to extract predictors from parsnip fit object

I have the following prediction model: library(tidymodels) data(ames) set.seed(4595) data_split <- initial_split(ames, strata = "Sale_Price", prop = 0.75) ames_train <- training(data_split) ames_test <- testing(data_split) rec <-…
littleworth
  • 4,781
  • 6
  • 42
  • 76
1
vote
1 answer

Custom recipe fails at prep

I have built custom recipes that I use in two of my packages. I suspect the issue may be the same across all. I will start with this one where the issue I am getting is at prep time as it is saying that the variable types are incorrect. Here is the…
MCP_infiltrator
  • 3,961
  • 10
  • 45
  • 82
1
vote
1 answer

Get the proportion of the variance explained in a plsda with recipes

I try to compute the proportion of the variance explained by each component in a PLSDA, using the tidymodels framework. Here's the "gold standard" result with the mixOmics package: library(mixOmics) mix_plsda <- plsda(X = iris[-5], Y =…
abichat
  • 2,317
  • 2
  • 21
  • 39
1
vote
1 answer

How do space-filling parameter grids change when we call them by parsnip and recipe packages?

According to this (https://dials.tidymodels.org/reference/grid_max_entropy.html) page, the output of a grid function may vary depending on whether we use a parameter object produced by parsnip and recipes, or we directly use a parameter object.…
Salivan
  • 157
  • 7
1
vote
1 answer

How to Exclude a Char Variable from recipes::step_dumm()?

How do I keep a character ID variable PERSON_ID unchanged in a recipe? I tried update_role(PERSON_ID , new_role = "id variable") and tried excluding it from step_dummy step_dummy(all_nominal_predictors(), -all_numeric_predictors(), -all_outcomes(),…
poshan
  • 3,069
  • 5
  • 20
  • 30
1
vote
0 answers

How to apply inverse hyperbolic sine using the repices package in R?

I am exploring the recipes package to prepare my data for linear regression. But even a simple transformation of two variables using inverse hyperbolic sine does not yield the results I am expecting. What am I getting wrong…
dufei
  • 2,166
  • 1
  • 7
  • 18
1 2
3
8 9