--The Data is in Excel file, first we are installing required libraries, if not already done.
--Our Target variable is Income, here in this code example.
install.packages("rpart")
install.packages("rpart.plot")
install.packages("readxl")
library(rpart)
library(rpart.plot)
library(readxl)
data = read_excel("C:\\Users\\Khan\\Downloads\\customer_dbase (1).xlsx")
selected_data <- customer_dbase[, c("age", "income")]
tree_model <- rpart(income ~ ., data = selected_data)
rpart.plot(tree_model)
No comments:
Post a Comment