Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. model2_cb<-function(widget, window){
  2. library(e1071)
  3. library(caret)
  4. dialog3 <- gtkFileChooserDialog("Choose the Train File", window, "ok",
  5. "gtk-cancel", GtkResponseType["cancel"], "gtk-open",
  6. GtkResponseType["accept"])
  7. if (dialog3$run() == GtkResponseType["accept"]) {
  8. df3 <- read.csv(dialog3$getFilename())
  9. data3<-data.frame(df3)
  10. dialog3$destroy()
  11. }
  12. dialog4 <- gtkFileChooserDialog("Choose the Test FIle", window, "ok",
  13. "gtk-cancel", GtkResponseType["cancel"], "gtk-open",
  14. GtkResponseType["accept"])
  15. if (dialog4$run() == GtkResponseType["accept"]) {
  16. df4 <- read.csv(dialog4$getFilename())
  17. data4<-data.frame(df4)
  18. dialog4$destroy()
  19. }
  20. data4$Class <- "Predicted Value"
  21. combined <- rbind(data3, data4)
  22. data4 <- combined[combined$Class == "Predicted Value" ,]
  23. data3 <- combined[combined$Class != "Actual Value" ,]
  24. svm.model3 <- svm(Class ~ ., data = data3, cost = 1000, gamma = 1)
  25. svm.pred3 <- predict(svm.model3, newdata = data4)
  26. table(pred = svm.pred3, true = data4[,7])
  27. xtab2<-table(pred = svm.pred3, true = data4[,7])
  28. confusionMatrix(xtab2)
  29. y1<-confusionMatrix(xtab2)
  30. cleanoutput2 <- cbind(df4,svm.pred3)
  31. colnames(cleanoutput2) <- c("IR","MR","FF","CF","CO","CP","Expected Output","Predicted Output")
  32. print(cleanoutput2)
  33. print(y1)
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement