Resampling imbalanced data
Now that we have an appropriate scoring method to discover exoplanets, it's time to explore strategies such as resampling, undersampling, and oversampling for correcting the imbalanced data causing the low recall score.
Resampling
One strategy to counteract imbalanced data is to resample the data. It's possible to undersample the data by reducing rows of the majority class and to oversample the data by repeating rows of the minority class.
Undersampling
Our exploration began by selecting 400 rows from 5,087. This is an example of undersampling since the subset contains fewer rows than the original.
Let's write a function that allows us to undersample the data by any number of rows. This function should return the recall score so that we can see how undersampling changes the results. We will begin with the scoring function.
The scoring function
The following function takes XGBClassifier and the number of rows as input and...