forked from mdelhey/kaggle-titanic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
6-ensemble.R
53 lines (40 loc) · 1.07 KB
/
6-ensemble.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
51
52
53
# Goal: (1) Combine our three models into one prediction:
# - randomForest
# - SVM
# - probit
# Source our data and clean it
source("1-clean.R")
# Source our models
source("2-randomForest.R")
source("3-SVM.R")
source("4-logit.R")
###
### Gather predictions
###
# randomForest
test$survived_rf <- predict(forest, test)
# SVM
test$survived_svm <- predict(svm.model, test, type = "response")
# Neural Net
test$survived_logit <- predict(logit, test, type = "response")
test$survived_logit[test$survived_logit >= 0.8] <- 2
test$survived_logit[test$survived_logit < 0.8] <- 1
###
### Combine Predictions
###
vote <- as.numeric(test$survived_rf) +
as.numeric(test$survived_svm) +
as.numeric(test$survived_logit)
# 0 is 0
# 4 is 0
# 5 is 1
# 6 is 1
combined <- vote
combined[combined <= 4] <- 0
combined[combined >= 5] <- 1
# Make our ensamble prediction
test$survived <- combined
write.csv(test, "Submissions/ensemble-14.csv")
# Compare to highest
highest <- read.csv("Submissions/highest.csv")
which(test$survived != highest$survived)