# How R randomforest sampsize works?

I am working on a predictive model (imbalanced data) and trying to undersample the majority class data. I wanted to get the representative sample of my majority class and somehow came to know about R's RandomForest which has a parameter "sampsize".

Can someone help me know how R's RandomForest subsamples the data? Maybe this can help solve my problem or maybe suggest me some other method?

I've tried getting centroid of the majority class data and undersampled my majority class by eliminating all the samples which are far away from this centroid of majority class but didn't get satisfactory results. I have around 50 features and working in python.

With sampsize you tell the model how many units to sample from each class. It is called with sampsize=c('0'=10,'1'=20) which means 10 units from the class '0' and 20 units from the class '1' (if you use different labels for the classes then change accordingly). With replace=T you tell the model to sample with replacement. So in this case it will sample 10 units from class 0 with replacement.
• @AmarpreetSingh How R randomforest sampsize works? That's the title of your question and that is what I answered. Nowhere in your question did you mention how I can manually make my data unbiased without information loss so that it improves the model accuracy. Also nowhere did you mention that sou are using python. Your question is either misleading or you are wrong. – user2974951 Mar 30 at 10:31