Skip to content
Advertisement

How do I save the data that has been randomly undersampled?

I am trying to balance a data frame by using random undersampling of the majority class. It has been successful, however, I also want to save the data that has been removed from the data frame (undersampled) to a new data frame. How do I accomplish this?

This is the code that I am using to undersample the data frame

JavaScript

Advertisement

Answer

RandomUnderSampler has an attribute sample_indices_, indicating the indices of the retained subsample. So this should do:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement