-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrf_benchmark.R
More file actions
43 lines (26 loc) · 966 Bytes
/
rf_benchmark.R
File metadata and controls
43 lines (26 loc) · 966 Bytes
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
# makes the random forest submission
library(randomForest)
train <- read.csv("data/train.csv", header=TRUE)
test <- read.csv("data/test.csv", header=TRUE)
labels <- as.factor(train[,1])
train <- train[,-1]
rf <- randomForest(train, labels, xtest=test, ntree=100)
predictions <- levels(labels)[rf$test$predicted]
plot(rf)
write(predictions, file="rf_benchmark.csv", ncolumns=1)
names(train)
library(party)
train <- read.csv("data/train.csv", header=TRUE)
test <- read.csv("data/test.csv", header=TRUE)
#ctree and cforest expect labels to be factors
train$label <- as.factor(train$label)
class(train$label)
partree <- ctree(label~., data=train[1:1000,])
plot(partree)
data.controls <- cforest_unbiased(ntree=100, mtry=28)
subset = 5000
cf<- cforest(label~., data=train[1:subset,],
control = data.controls)
table(predict(cf), train[1:subset,1])
sum(predict(cf) == train[1:subset,1])/subset
tr <- treeresponse(cf, newdata = test[1:100,])