On May 11, 2010, at 6:49 PM, Changbin Du wrote:

HI, Dear R community,

How to extract the variables actually used in tree construction? I want to extract these variables and combine other variable as my features in next
step model building.

help(package=rpart, rpart.object)



printcp(fit.dimer)


Perhaps:

fit.dimer$terms


Classification tree:
rpart(formula = outcome ~ ., data = p_df, method = "class")

Variables actually used in tree construction:
[1] CT DP DY FC NE NW QT SK TA WC WD WG WW YG

Root node error: 608/1743 = 0.34882

n= 1743

       CP nsplit rel error  xerror     xstd
1 0.185033      0   1.00000 1.00000 0.032726
2 0.052632      2   0.62993 0.65132 0.028773
3 0.026316      4   0.52467 0.58059 0.027596
4 0.025768      5   0.49836 0.57072 0.027419
5 0.019737      8   0.42105 0.56086 0.027239
6 0.018092      9   0.40132 0.55263 0.027087
7 0.013158     12   0.34704 0.52796 0.026616
8 0.011513     13   0.33388 0.50000 0.026056
9 0.010000     15   0.31086 0.48520 0.025748


THanks so much!

--
Sincerely,
Changbin
--

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to