[R] random forest question

Christian Hennig fm3a004 at math.uni-hamburg.de
Tue Jan 20 10:59:05 CET 2004


Hi,

here are three results of random forest (version 4.0-1).
The results seem to be more or less the same which is strange because I
changed the classwt. 
I hoped that for example classwt=c(0.45,0.1,0.45) would result in fewer
cases classified as class 2. Did I understand something wrong?

Christian

x1rf <- randomForest(x=as.data.frame(mfilters[cvtrain,]),
                     y=as.factor(traingroups),
                     xtest=as.data.frame(mfilters[cvtest,]),
                     ytest=as.factor(testgroups))
> x1rf$test$confusion
     1    2  3 class.error
1 9954   30 19  0.00489853
2  139 1854  0  0.06974410
3  420    0 84  0.83333333
x1rf <- randomForest(x=as.data.frame(mfilters[cvtrain,]),
                     y=as.factor(traingroups),
                     xtest=as.data.frame(mfilters[cvtest,]),
                     ytest=as.factor(testgroups),classwt=c(0.45,0.1,0.45))
> x1rf$test$confusion
     1    2  3 class.error
1 9952   31 20  0.00509847
2  164 1828  1  0.08278976
3  440    0 64  0.87301587
x1rf <- randomForest(x=as.data.frame(mfilters[cvtrain,]),
                     y=as.factor(traingroups),
                     xtest=as.data.frame(mfilters[cvtest,]),

ytest=as.factor(testgroups),classwt=c(0.49,0.02,0.49))
> x1rf$test$confusion
     1    2  3 class.error
1 9948   35 20  0.00549835
2  170 1823  0  0.08529854
3  439    0 65  0.87103175



***********************************************************************
Christian Hennig
Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg
hennig at math.uni-hamburg.de, http://www.math.uni-hamburg.de/home/hennig/
#######################################################################
ich empfehle www.boag-online.de




More information about the R-help mailing list