getwd()
sessionInfo()
#*******************************************************************************
# Lista de paquetes y funciones a instalar
.packages = c(
  "mlbench",                # leer raster
  "caret" ,                   # leer raster
  "e1071"
)
# Si no estan instalados los paquetes, instalar automaticamente
.inst <- .packages %in% installed.packages()
if(length(.packages[!.inst]) > 0) install.packages(.packages[!.inst])
.libPaths()    # chek libraries

# Si no estan cargados los paquetes, cargar paquetes y funciones
lapply(.packages, require, character.only=TRUE)


# Rank features by their importance.

# load the libraries
library(mlbench)
library(caret)
library(e1071)
# load the dataset
data(PimaIndiansDiabetes)
datos <- PimaIndiansDiabetes
# prepare training scheme
control <- trainControl(method="cv", number=10)
# train the model
model <- train(diabetes~., data=datos, method="lvq", preProcess="scale", trControl=control)
# estimate variable importance
importance <- varImp(model, scale=FALSE)
# summarize importance
print(importance)
# plot importance
plot(importance)
