# How to do the right sampling for a classification model

I'm looking for the best sampling method for classification modeling (logistic regression OR Xgboost ) that will decrease the number of observations in the training data set while keeping the bias and variance as low as possible. Is there any function or rule of thumb that I can use in order to get to this goal ? I currently use this method (code in R) but I'm not sure that it the best for both algorithms (logistic regression OR Xgboost ):

prb <- ifelse(df_train\$TargetVar=='1',1,0.5)
smpl <- df_train[sample(nrow(df_train), as.numeric(nrow(df_train) * 0.2) , prob = prb),]