Advertisement
Guest User

decisionTree

a guest
Feb 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.56 KB | None | 0 0
  1. library(RWeka)
  2. library(caret)
  3. library(e1071)
  4. library(rpart)
  5. DB <- read.csv("/home/onu/Desktop/ML/Imtiaz/data.csv")
  6. DB$class <- as.character(DB$class)
  7. DB$class <- as.factor(DB$class)
  8. DB$ind <- sample(2,nrow(DB),replace=TRUE,prob=c(0.7,0.3))
  9. trainData <- DB[(DB$ind == 1),]
  10. testData <- DB[(DB$ind ==2),]
  11. model <- J48(class~age+gender+tB+dB+alkphos+sgpt+sgot+tP+al.B+aG,data=trainData)
  12. model
  13. head(testData)
  14. x_test <- testData[,1:10]
  15. prediction <- predict(model,x_test)
  16. testData1 <- na.omit(testData)
  17. prediction
  18. confusionMatrix(testData$class,prediction)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement