This question already has an answer here:
My data set is imbalanced - 5% of the target class represents fraudulent transactions, 95% of the target class represents legitimate transactions. I must use the whole data set, as the 95% of legitimate transactions are important for training. How can I use undersampling within algorithms such as rpart (decision tree), naive bayes, neural networks, SVM, etc. to create, run and evaluate using multiple splits of the data. For example: the number of legitimate transactions is equal to the number of fraudulent. So 5% and 5%. This is instead of the typical way of cutting down the data set to 50% legitimate, 50% fraud where you would lose 85% of the legitimate transactions. I cannot oversample by generating randomized data in this case.