Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.11 KB | None | 0 0
  1. # Zadanie 3
  2.  
  3. depression <- c(6,4,0,4,0,11,11,5,8,4,12,8,9,8,11)
  4. anxiety <- c(8,3,2,1,8,9,6,7,6,9,11,8,6,10,4)
  5. chaos <- c(9,3,8,6,4,9,6,4,5,4,6,5,7,8,3)
  6. group <- c("g1", "g1", "g1", "g1", "g1", "g2", "g2", "g2", "g2", "g2", "g3", "g3", "g3", "g3", "g3")
  7.  
  8. data.set <- data.frame(depression, anxiety, chaos, group)
  9. ctrl.loo <- trainControl(method = "LOOCV", search = "grid")
  10.  
  11. # metoda liniowa
  12. model.lda <- train(group ~ depression + anxiety + chaos,
  13.                    data = data.set,
  14.                    method = 'lda',
  15.                    trControl = ctrl.loo)
  16.  
  17. # metoda kwadratowa
  18. model.qda <- train(group ~ depression + anxiety + chaos,
  19.                    data = data.set,
  20.                    method = 'qda',
  21.                    trControl = ctrl.loo)
  22.  
  23. # bayes
  24. model.nb <- train(group ~ depression + anxiety + chaos,
  25.                    data = data.set,
  26.                    method = 'nb',
  27.                    trControl = ctrl.loo,
  28.                   tuneGrid = data.frame(usekernel = FALSE, fL = 0, adjust = 1))
  29.  
  30. #LDA
  31. 1 - model.lda$results[2]
  32. #QDA
  33. 1 - model.qda$results[2]
  34. #BAYES
  35. 1 - model.nb$results[4]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement