[R] help with RandomForest classwt option

Jim Porzak jporzak at gmail.com
Mon Jan 29 05:19:43 CET 2007


See Andy's previous post on this.

-- 
HTH,
Jim Porzak
Loyalty Matrix Inc.
San Francisco, CA


===============
Liaw, Andy <andy_liaw at merck.com> 	Thu, Oct 27, 2005 at 8:37 AM
To: "David L. Van Brunt, Ph.D." <dlvanbrunt at gmail.com>, Gabor
Grothendieck <ggrothendieck at gmail.com>
Cc: r-help at stat.math.ethz.ch
"classwt" in the current version of the randomForest package doesn't work
too well.  (It's what was in version 3.x of the original Fortran code by
Breiman and Cutler, not the one in the new Fortran code.)  I'd advise
against using it.

"sampsize" and "strata" can be use in conjunction.  If "strata" is not
specified, the class labels will be used.  Take the iris data as an example:

randomForest(Species ~ ., iris, sampsize=c(10, 30, 10))

says to randomly draw 10, 30 and 10 from the three species (with
replacement) to grow each tree.  If you are unsure of the labels, use named
vector, e.g.,

randomForest(Species ~ ., iris,
            sampsize=c(setosa=10, versicolor=30, virginica=10))

Now, if you want the stratified sampling to be done using a different
variable than the class labels; e.g., for multi-centered clinical trial
data, you want to draw the same number of patients per center to grow each
tree (I'm just making things up, not that that necessarily makes any sense),
you can do something like:

randomForest(..., strata=center,
            sampsize=rep(min(table(center))), nlevels(center)))

which draws the same number of patients (minimum at any center) from each
center to grow each tree.

Hope that's clear.  Eventually all such things will be in the yet to be
written package vignette...

Andy


On 1/28/07, Betty Health <betty.health at gmail.com> wrote:
> Hello there,
>
> I am working on an extremely unbalanced two class classification problems. I
> wanna use "classwt" with "down sampling" together. By checking the rfNews()
> in R, it looks that classwt is not working yet. Then I looked at the
> software from Salford. I did not find the down sampling option.  I am
> wondering if you have any experience to deal with this problem. Do you know
> any method or softwares can handle this problem?
>
> Thank you very much!!
>
> Betty
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list