The data I use is the heart disease data from UCI repository, and it looks like
> head(Hungarian)
age sex cp trestbps chol fbs restecg thalach exang oldpeak slope ca thal num
1 28 1 2 130 132 0 2 185 0 0 <NA> NA <NA> 0
2 29 1 2 120 243 0 0 160 0 0 <NA> NA <NA> 0
3 29 1 2 140 NA 0 0 170 0 0 <NA> NA <NA> 0
4 30 0 1 170 237 0 1 170 0 0 <NA> NA 6 0
5 31 0 2 100 219 0 1 150 0 0 <NA> NA <NA> 0
6 32 0 2 105 198 0 0 165 0 0 <NA> NA <NA> 0
The class variable is the variable num (0 or 1). And the result of typing dput(mytree)
is
structure(list(classifier = new("jobjRef", jobj = <pointer: 0x0de0e848>,
jclass = "java/lang/Object"), predictions = structure(c(1L,
1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L,
2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L,
1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L), .Label = c("0",
"1"), class = "factor"), call = J48(formula = num ~ ., data = train.set,
na.action = NULL, control = Weka_control(U = TRUE, B = FALSE)),
handlers = list(data = function (mf)
{
terms <- attr(mf, "terms")
if (any(attr(terms, "order") > 1L))
stop("Interactions are not allowed.")
factors <- attr(terms, "factors")
varnms <- rownames(factors)[c(TRUE, rowSums(factors)[-1L] >
0)]
mf[, sub("^`(.*)`$", "\\1", varnms), drop = FALSE]
}), levels = c("0", "1"), terms = num ~ age + sex + cp +
trestbps + chol + fbs + restecg + thalach + exang + oldpeak +
slope + ca + thal), class = c("J48", "Weka_tree", "Weka_classifier"
))
Thanks a lot.
dput(mytree)
and paste the results into your question so that we can try to figure out why your tree is causing problems. – G5W