Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. ---
  2. title: "Week4"
  3. output: html_document
  4. ---
  5.  
  6. ```{r }
  7. knitr::opts_knit$set(root.dir = 'E:/Lecture4')
  8. getwd()
  9.  
  10. ```
  11.  
  12.  
  13. ```{r}
  14. df <- read.csv("train.csv", nrows=20000)
  15. ```
  16.  
  17. ```{r}
  18. summary(df)
  19. ```
  20.  
  21.  
  22. ```{r}
  23. #install.packages("rpart")
  24. seed=123
  25. set.seed(seed) # set the random seed to get the same results at each execution
  26. library(rpart)
  27. train.rpart <- rpart(loss ~ ., data = df, control=rpart.control(maxdepth = 3))
  28. ```
  29.  
  30.  
  31.  
  32. ```{r}
  33. #install.packages(c("rattle","rpart.plot"))
  34. library(rattle)
  35. library(rpart.plot)
  36. fancyRpartPlot(train.rpart, cex=0.7)
  37. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement