Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.89 KB | None | 0 0
  1. group_wo_ex <- group
  2. group_wo_ex$experts..0 <- NULL
  3. group_wo_ex$experts..1 <- NULL
  4. group_wo_ex$experts..2 <- NULL
  5. group_wo_ex$experts..3 <- NULL
  6. group_wo_ex$experts..4 <- NULL
  7. group_wo_ex$experts..5 <- NULL
  8. group_wo_ex$sum <- NULL
  9.  
  10. dataset <- group_wo_ex
  11.  
  12. dataset_ratio <- gain.ratio( consensus~., dataset)
  13. dataset_ratio <- t(dataset_ratio)
  14. names <- colnames( t (dataset_ratio[, which(dataset_ratio>0.07)]))
  15. dataset_w_ratio <- dataset[names]
  16. dataset_w_ratio$consensus <- dataset$consensus
  17. #View(dataset_w_ratio)
  18. grid <- expand.grid(k = c(3,5,7,9,15,19,21,23,25,27,29,31,33))
  19.  
  20. # define training control
  21. train_control <- trainControl(method="cv", number=10)
  22. testknn <- train(dataset_w_ratio, dataset_w_ratio$consensus, method="knn", tuneGrid=grid, preProcess=c("center", "scale"))
  23. testnb <- train(dataset_w_ratio, dataset_w_ratio$consensus, method="nb", preProcess=c("center", "scale"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement