Sorry if the title is a bit confusing, I don't know how else can I make this question more specific.
I am trying to create an Adaboost implementation in Python, I am using the MNIST from Keras datasets.
Currently, I am just trying to create a training array for a weak threshold that classifies the "0" number images.
For that, I need to create an array, half of it being just images of "0", and the other half being any other random number.
Currently, I have 2 arrays, x_train
: an array that contains the pictures and y_train
: an array that contains the tag, that way we can check if, for example, x_train[i]
is a picture of the number "0" if y_train[i] == 0
.
So, I want to know if there's an automated way of doing that using NumPy, to grab elements from an array using a condition applied to another array.
Basically: Grab n elements and push into custom_array from x_array[i] if y_array[i] == 0 , and, grab n elements and push into custom_array from x_array[i] if y_array[i] != 0.
Best regards.
Does this serve your purpose?
mask = y_array == 0
array_0 = x_array[mask]
array_non0 = x_array[~mask]
If I interpreted your question the wrong way, please correct me.