Select array entries with another array
Using where()
and take()
import numpy as np
y_pred = np.array([1,0,0,1,1,0,0])
y_true = np.array([1,0,1,1,1,1,0])
test_files = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
np.where(y_pred != y_true)
(array([2, 5]),)
np.take(test_files,np.where(y_pred != y_true)[0])
array(['c', 'f'], dtype='<U1')