Re: [R] oversampling code

2011-11-01 Thread Kevin E. Thorpe
On 11/01/2011 12:32 PM, loubna181 wrote: Hi, Thanks all for your responses, but as I m a new user of R while trying to apply what David suggests I dont know what *"dorm" *refers to. dfrm[c(rownames(dfrm[*dorm*$Y==1,]), sample(rownames(dfrm[dfrm$Y==0]), 0.10)) , ] I suspect that dorm was a typo

Re: [R] oversampling code

2011-11-01 Thread loubna181
Hi, Thanks all for your responses, but as I m a new user of R while trying to apply what David suggests I dont know what *"dorm" *refers to. dfrm[c(rownames(dfrm[*dorm*$Y==1,]), sample(rownames(dfrm[dfrm$Y==0]), 0.10)) , ] But to give you more details , I'm working on a table calles balance from

Re: [R] oversampling code

2011-10-31 Thread Weidong Gu
You should figure out how many samples you want for Y=1 and 0, then sample from the relevant subset dfrm[dfrm$Y==1] by sampling row.names(dfrm[dfrm$Y==1] using replace=FALSE ?sample On Mon, Oct 31, 2011 at 8:18 PM, Comcast wrote: > > > On Oct 31, 2011, at 1:54 PM, loubna ibn majdoub hassani > w

Re: [R] oversampling code

2011-10-31 Thread Comcast
On Oct 31, 2011, at 1:54 PM, loubna ibn majdoub hassani wrote: > Hir > I have an umbalanced data set where I want to predict a binary variable Y. > I want to do an under sampling by keeping all the 1 and taking just some of > the 0 such as I'll have 90% of 0 and 10% of 1. ou haven' t given mu

Re: [R] oversampling code

2011-10-31 Thread Weidong Gu
For a data set dat with variable 'case', it follows sam.rate=0.9 n.ctrl<-nrow(dat[dat$case==0,]) sam.ctrl<-dat[sample(row.names(dat[dat$case==0],n.ctrl*sam.rate,replace=F),] rbind(dat[dat$case==1,],sam.ctrl) Weidong Gu On Mon, Oct 31, 2011 at 1:54 PM, loubna ibn majdoub hassani wrote: > Hi > I

[R] oversampling code

2011-10-31 Thread loubna ibn majdoub hassani
Hi I have an umbalanced data set where I want to predict a binary variable Y. I want to do an under sampling by keeping all the 1 and taking just some of the 0 such as I'll have 90% of 0 and 10% of 1. Can u help me do that Thank u [[alternative HTML version deleted]] _