April 2018
Beginner to intermediate
300 pages
7h 34m
English
We first revert the labels from one-hot format back to lists of integers:
y_test1 = model.predict(X_test)y_test1 = lb.fit_transform(np.round(y_test1))y_test1 = np.argmax(y_test1, axis=1)y_test = np.argmax(y_test, axis=1)
We will extract the indices of mislabeled images, and use them to retrieve the corresponding true and predicted labels:
import numpy as npmislabeled_indices = np.arange(len(y_test))[y_test!=y_test1]true_labels = np.asarray([y_test[i] for i in mislabeled_indices])predicted_labels = np.asarray([y_test1[i] for i in mislabeled_indices])print(mislabeled_indices)print(true_labels)print(predicted_labels)
The output is as follows, with NumPy arrays of the indices, true and predicted ...
Read now
Unlock full access