# Box-Cox Transform (attributes must be numeric and >0)

# load libraries
library(mlbench)
library(caret)
library(e1071)
# load the dataset
data(PimaIndiansDiabetes)
datos <- PimaIndiansDiabetes
x <- datos[,7:8]
y <- datos[,9]
# summarize pedigree and age
summary(x)
# calculate the pre-process parameters from the dataset
preprocessParams <- preProcess(x, method=c("BoxCox"))
# summarize transform parameters
print(preprocessParams)
# transform the dataset using the parameters
x_bc <- predict(preprocessParams, x)
# summarize the transformed dataset (note pedigree and age)
summary(x_bc)


scales <- list(x=list(relation="free"), y=list(relation="free"))
# ejes adaptados a cada variable
featurePlot(x=x, y=y, plot="density", scales=scales)
featurePlot(x=x_bc, y=y, plot="density", scales=scales)
