DATABASE-6-PART-2-DECISION TREE

RANDOM FOREST

Author

GG21

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

#load libraries

#install.packages("caret")
#install.packages("rpart")
#install.packages("rattle")
#install.packages("e1071")
#install.packages("rpart.plot")
#install.packages("RColorBrewer")
#install.packages("ROCR")

library(caret)
library(rpart)
library(rattle)
library(e1071)
library(rpart.plot)
library(RColorBrewer)
library(ROCR)

#install.packages("randomForest")
#install.packages("pROC")

library(randomForest)
library(pROC)
require(caTools)
AdventureWorksDW <- read.csv("C:/Users/ggarrido/Downloads/AdventureWorksDataMiningInput.csv")
head(AdventureWorksDW)
  MaritalStatus Gender YearlyIncome TotalChildren NumberChildrenAtHome
1             M      M         High             2                    0
2             S      M     Moderate             3                    3
3             M      M     Moderate             3                    3
4             S      F         High             0                    0
5             S      F         High             5                    5
6             S      M         High             0                    0
  EducationLevel   Occupation HouseOwnerFlag NumberCarsOwned
1      Bachelors Professional              1               0
2      Bachelors Professional              0               1
3      Bachelors Professional              1               1
4      Bachelors Professional              0               1
5      Bachelors Professional              1               4
6      Bachelors Professional              1               1
  FirstPurchaseYearMonth CommuteDistance  Region AgeRange BikeBuyer
1                 201801          1 to 2 Pacific      50s     Buyer
2                 201801          0 to 1 Pacific      40s     Buyer
3                 201801          2 to 5 Pacific      50s     Buyer
4                 201712         5 to 10 Pacific      40s     Buyer
5                 201801          1 to 2 Pacific      40s     Buyer
6                 201712         5 to 10 Pacific      40s     Buyer