Exercise

Combining ROS & RUS

You can combine both random over-sampling (ROS) and random under-sampling (RUS) in order to balance the class distribution. You're going to re-balance the dataset such that the new dataset contains 10,000 transactions of which 30% are fraudulent.

Remember, you can always load ROSE in the console and enter ?ovun.sample to check which arguments the function takes.

Instructions

100 XP
  • Load the ROSE package.
  • Set n_new equal to 10,000 and fraud_fraction to 30%.
  • Use both over and under-sampling.
  • Check the class-balance of the under-sampled dataset.