forked from mlr-org/mlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_classif_randomForestSRC.R
31 lines (27 loc) · 1.08 KB
/
test_classif_randomForestSRC.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
test_that("classif_randomForestSRC", {
skip_on_os("mac")
requirePackagesOrSkip("randomForestSRC", default.method = "load")
parset.list = list(
list(ntree = 200),
list(ntree = 350, mtry = 5L),
list(ntree = 250, nodesize = 2, na.action = "na.impute",
importance = "permute", proximity = FALSE)
)
old.predicts.list = list()
old.probs.list = list()
for (i in seq_along(parset.list)) {
parset = parset.list[[i]]
parset = c(parset, list(data = binaryclass.train,
formula = binaryclass.formula, forest = TRUE))
set.seed(getOption("mlr.debug.seed"))
m = do.call(randomForestSRC::rfsrc, parset)
p = predict(m, newdata = binaryclass.test, membership = FALSE,
na.action = "na.impute")
old.predicts.list[[i]] = p$class
old.probs.list[[i]] = p$predicted[, 1]
}
testSimpleParsets("classif.randomForestSRC", binaryclass.df,
binaryclass.target, binaryclass.train.inds, old.predicts.list, parset.list)
testProbParsets("classif.randomForestSRC", binaryclass.df,
binaryclass.target, binaryclass.train.inds, old.probs.list, parset.list)
})