-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStep3.2_DecisionTree.R
50 lines (35 loc) · 1.17 KB
/
Step3.2_DecisionTree.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 3.2 Decision Tree
# source: http://www.rdatamining.com/examples/decision-tree
library(grid)
library(mvtnorm)
library(modeltools)
library(stats4)
library(party)
# Read CSV file
myData <- read.csv("Airline_data_Gender.csv")
# View(myData)
# ------------------------------------------------------------------------------ #
# 4 Attributes: "SUCCESS","Age","SEATCLASS","Gender"
# Preprocess data
myData <- myData[,c("SUCCESS","Age","SEATCLASS","Gender")]
# View(myData)
# Implementation for Dataframe
str(myData)
#
myData_ctree <- ctree(Gender ~SUCCESS + Age + SEATCLASS, data = myData)
print(myData_ctree)
plot(myData_ctree)
plot(myData_ctree, type="simple")
# ------------------------------------------------------------------------------ #
# 5 Attributes: "SUCCESS","Age","SEATCLASS","GUESTS","Gender"
# Preprocess data
myData <- myData[,c("SUCCESS","Age","SEATCLASS","GUESTS","Gender")]
# View(myData)
# Implementation for Dataframe
str(myData)
#
myData_ctree <- ctree(Gender ~SUCCESS + Age + SEATCLASS + GUESTS, data = myData)
print(myData_ctree)
plot(myData_ctree)
plot(myData_ctree, type="simple")
# ------------------------------------------------------------------------------ #