简体   繁体   English

反规范化 R 中的数据

[英]De normalize data in R

I apply normalization function to my data with this code:我使用以下代码将规范化 function 应用于我的数据:

normalize <- function(x) { return ((x - min(x)) / (max(x) - min(x)))}

Then I applied the function to my data, only for numeric variables.然后我将 function 应用于我的数据,仅用于数字变量。

bankfull[,c(1,6,10,12:15)]= as.data.frame(lapply(bankfull[,c(1,6,10,12:15)], normalize))

Can someone help me to revert normalization?有人可以帮我恢复正常化吗?

Thank you in advance.先感谢您。

There's a package DMwR that unscales sets of values and is worth a shot, even though there are pitfalls to watch out for like John mentioned in the comments.有一个 package DMwR可以取消缩放值集并且值得一试,即使像评论中提到的 John 一样需要注意陷阱。 For example, with 100 observations normally distributed with mean of 5 and stdev of 1:例如,100 个观测值正态分布,均值为 5,标准差为 1:

library(DMwR)
a <- rnorm(100,5,1)
hist(a)

在此处输入图像描述

b <- scale(a)
c <- DMwR::unscale(b,b)

Now you can compare the values by subtracting ac (you get all nearly-zeroes) or plotting a vs c (which shows the equivalents):现在您可以通过减去ac (您得到所有接近零的值)或绘制 a vs c(显示等价物)来比较这些值:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM