|
a |
|
b/partyMod/tests/Node-regtest.R |
|
|
1 |
|
|
|
2 |
set.seed(290875) |
|
|
3 |
library("party") |
|
|
4 |
if (!require("TH.data")) |
|
|
5 |
stop("cannot load package TH.data") |
|
|
6 |
|
|
|
7 |
### get rid of the NAMESPACE |
|
|
8 |
attach(asNamespace("party")) |
|
|
9 |
|
|
|
10 |
gtctrl <- new("GlobalTestControl") |
|
|
11 |
tlev <- levels(gtctrl@testtype) |
|
|
12 |
|
|
|
13 |
data(GlaucomaM, package = "TH.data") |
|
|
14 |
inp <- initVariableFrame(GlaucomaM[,-63,drop = FALSE], trafo = NULL) #, fun = rank) |
|
|
15 |
resp <- initVariableFrame(GlaucomaM[,"Class",drop = FALSE], trafo = NULL, response = TRUE) |
|
|
16 |
ls <- new("LearningSample", inputs = inp, responses = resp, |
|
|
17 |
weights = rep(1, inp@nobs), nobs = nrow(GlaucomaM), |
|
|
18 |
ninputs = inp@ninputs) |
|
|
19 |
tm <- ctree_memory(ls, TRUE) |
|
|
20 |
ctrl <- ctree_control() |
|
|
21 |
node <- .Call("R_Node", ls, ls@weights, tm, ctrl, PACKAGE = "party") |
|
|
22 |
stopifnot(isequal(node[[5]][[3]], 0.059)) |
|
|
23 |
|
|
|
24 |
### and now with ranked inputs -> Wilcoxon-Mann-Whitney tests |
|
|
25 |
inp <- initVariableFrame(GlaucomaM[,-63,drop = FALSE], trafo = function(data) |
|
|
26 |
ptrafo(data, numeric_trafo = rank)) |
|
|
27 |
resp <- initVariableFrame(GlaucomaM[,"Class",drop = FALSE], trafo = NULL, response = TRUE) |
|
|
28 |
ls <- new("LearningSample", inputs = inp, responses = resp, |
|
|
29 |
weights = rep(1, inp@nobs), nobs = nrow(GlaucomaM), |
|
|
30 |
ninputs = inp@ninputs) |
|
|
31 |
tm <- ctree_memory(ls, TRUE) |
|
|
32 |
ctrl <- ctree_control() |
|
|
33 |
node <- .Call("R_Node", ls, ls@weights, tm, ctrl, PACKAGE = "party") |
|
|
34 |
stopifnot(isequal(node[[5]][[3]], 0.059)) |