Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- title: "Week4"
- output: html_document
- ---
- ```{r }
- knitr::opts_knit$set(root.dir = 'E:/Lecture4')
- getwd()
- ```
- ```{r}
- df <- read.csv("train.csv", nrows=20000)
- ```
- ```{r}
- summary(df)
- ```
- ```{r}
- #install.packages("rpart")
- seed=123
- set.seed(seed) # set the random seed to get the same results at each execution
- library(rpart)
- train.rpart <- rpart(loss ~ ., data = df, control=rpart.control(maxdepth = 3))
- ```
- ```{r}
- #install.packages(c("rattle","rpart.plot"))
- library(rattle)
- library(rpart.plot)
- fancyRpartPlot(train.rpart, cex=0.7)
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement