"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

June 01, 2016

Day #25 - Data Transformations in R

This post is on performing Data Transformations in R. This would be part of feature modelling. Advanced PCA will be done during later stages



#Data for column attributes
Y0 = 1:20 + rnorm(100,sd=3)
Y1 = 1:20 + rnorm(100,sd=2)
Y2 = 1:20 + rnorm(100,sd=2)
Y3 = 1:20 + rnorm(100,sd=2)
Y4 = 1:20 + rnorm(100,sd=2)
Y5 = 1:20 + rnorm(100,sd=3)
Y6 = 1:10 + rnorm(100,sd=3)
Y7 = 1:10 + rnorm(100,sd=2)
Y8 = 1:20 + rnorm(100,sd=1)
#Create Data Frame
data <- data.frame(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8)
#sample few records
head(data)
#Ways to normalize Data
data$Y0 = (x-min(data$Y0))/(max(data$Y0)-min(data$Y0))
#Raises Y to the power of 3
data$Y1 <- (data$Y1)^3
#Takes the ninth root of Y
data$Y2 <- (data$Y2)^(1/9)
#Takes the natural logarithm (ln) of Y
data$Y3 <- log(data$Y3)
#Takes the base-10 logarithm of Y
data$Y4 <- log10(data$Y4)
#Raises the constant e to the power of Y
data$Y5 <- exp(data$Y5)
#Finds the absolute value of Y
data$Y6 <- abs(data$Y6)
#Calculates the sine of Y
data$Y7 <- sin(data$Y7)
#Calculates the inverse sine (arcsine) of Y
data$Y8 <- asin(data$Y8)
#check modified data
head(data)
Data Normalization in Python

Happy Learning!!!

No comments: