2

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 ~ ., data = dd)

transformation <- model_recipe %>%
  step_orderNorm(all_numeric()) %>% #power transformation
  step_normalize(all_predictors())

train_data <- prep(transformation, training = dd) %>%
  bake(dd)

The problem is I cant find any denormalizing tool in the tidymodel workflow

Azam Yahya
  • 646
  • 1
  • 7
  • 10

1 Answers1

0

A the moment of writing this there is no step_undo or workflow option, so you should do it manually:

x=1:5
x
#[1] 1 2 3 4 5

normalized = (x-min(x))/(max(x)-min(x))
normalized
#[1] 0.00 0.25 0.50 0.75 1.00

denormalized = (normalized)*(max(x)-min(x))+min(x)
denormalized
#[1] 1 2 3 4 5

When modeling you could do something like that: https://stats.stackexchange.com/a/209884/7387

jrosell
  • 1,445
  • 14
  • 20