August 2018
Intermediate to advanced
522 pages
12h 45m
English
The most common way to address this issue is based on a resampling procedure. This approach is extremely simple, but, unfortunately, it has many drawbacks. Considering the previous example, we could decide to upsample the class 1, so as to match the number of samples belonging to class 0. However, we can only use the existing data and, after every sampling step, we restart from the original dataset (replacement). To better understand the procedure, let's suppose that we generate the dataset by employing the scikit-learn make_classification function (we are going to use it lots of times in the upcoming chapters):
from sklearn.datasets import make_classificationnb_samples = 1000weights = (0.95, 0.05)X, Y = make_classification(n_samples=nb_samples, ...
Read now
Unlock full access