how to create a classification decision tree on weight from the data set ncbirths from Openintro free site

library(rpart)
library(rpart.plot)

set.seed(123)

load(file = "ncbirths.Rdata")
head(ncbirths)

library(rpart)
library(rpart.plot)

set.seed(123)

train_index <- sample(1:nrow(ncbirths), size = 0.7 * nrow(ncbirths))
train <- ncbirths[train_index, ]
test <- ncbirths[-train_index, ]

tree <- rpart(weight ~ ., data = train, method = "class")

rpart.plot(tree, main = "Decision Tree for the ncbirths Dataset",box.palette = "blue", shadow.col = 0)

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.