[英]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 .使用tidymodels作为在 R 中开发模型的新工作流程,我如何使用tidymodels 对功率变换数据进行非规范化/反转。
dd <- data.frame(x1=1:5,x2 = 11:15,y=6:10)
. dd <- data.frame(x1=1:5,x2 = 11:15,y=6:10)
。
Now using the tidy model framework:现在使用整洁的 model 框架:
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问题是我在 tidymodel 工作流程中找不到任何非规范化工具
A the moment of writing this there is no step_undo or workflow option, so you should do it manually:在写这篇文章的那一刻,没有 step_undo 或工作流选项,所以你应该手动做:
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建模时,您可以这样做: https://stats.stackexchange.com/a/209884/7387
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.