I normalized data with the minimum and maximum with this R code:
normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x)))
}
mydata <- as.data.frame(lapply(mydata , normalize))
How can I denormalize the data ?
I normalized data with the minimum and maximum with this R code:
normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x)))
}
mydata <- as.data.frame(lapply(mydata , normalize))
How can I denormalize the data ?
Essentially, you just have to reverse the arithmetic:
x1 = (x0-min)/(max-min)
implies thatx0 = x1*(max-min) + min
. However, if you're overwriting your data, you'd better have stored the min and max values before you normalized, otherwise (as pointed out by @MrFlick in the comments) you're doomed.Set up data:
Normalize:
Denormalize:
A cleverer
normalize
function would attach the scaling variables to the result as attributes (see the?scale
function ...)