-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdt2.R
40 lines (32 loc) · 941 Bytes
/
dt2.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
data.df<-read.csv(paste("dm.csv",sep=","))
View(data.df)
library(rpart)
train<-data.df[1:500,]
View(train)
library(rpart)
library(rpart.plot)
binary.fit<-rpart(Status ~ Age+Gender+AwaitingTime+Alcoolism + HiperTension +
Scholarship + Smokes + Sms_Reminder, data = train, method = "class",
minsplit=50, minbucket=1, cp=0.001)
plot(binary.fit)
text(binary.fit)
rpart.plot(binary.fit)
summary(binary.fit)
pred <- predict(binary.fit, train)
pred
library(lattice)
library(ggplot2)
library(caret)
library(gmodels)
t<-table(train$Status, pred[,1]>0.5)
t
T<-CrossTable(pred)
#need confusion mtrix for fp,fn,tp,tn
#need to show model accuracy
#
pred <- as.data.frame(pred)
predicted_values <- ifelse(pred[,2] < 0.5, "No-Show", "Show-up")
predicted_values <- as.factor(predicted_values)
actual_values <- train$Status
library(gmodels)
CrossTable(actual_values, predicted_values)