Skip to content

Instantly share code, notes, and snippets.

View satishgunjal's full-sized avatar
💭
Analytics | CX Architect | Conversational AI | Chatbots | Machine Learning

Satish Gunjal satishgunjal

💭
Analytics | CX Architect | Conversational AI | Chatbots | Machine Learning
View GitHub Profile
i = 49
plt.figure(figsize=(12,6))
plt.subplot(1,2,1)
plot_image(i, predictions_single[0], test_labels, test_images)
plt.subplot(1,2,2)
plot_value_array(i, predictions_single[0], test_labels)
_ = plt.xticks(range(10), class_names, rotation=45)
plt.show()
predictions_single = probability_model.predict(img)
# Remember that if we do "predictions = probability_model.predict(test_images)" then we get predictions for all test data"
print(f'Probabilty for all classes: {predictions_single}, \nBest confidence score for class: {np.argmax(predictions_single)}')
@satishgunjal
satishgunjal / gist:307e024b5dc07208a0b4f35ee2a06226
Created October 17, 2020 07:55
Add the image to a batch where it's the only member.
# Add the image to a batch where it's the only member.
img = (np.expand_dims(img, 0))
print(img.shape)
@satishgunjal
satishgunjal / gist:ce970f9b4819b2313396ee7addd61609
Created October 17, 2020 07:54
Grab an image from the test dataset.
# Grab an image from the test dataset.
img = test_images[49]
print(img.shape)
@satishgunjal
satishgunjal / gist:0f69b4a8ca9d96c96a4084606989c8d7
Last active October 17, 2020 12:15
Plot the test images from 'test_list', their predicted labels, and the true labels.
# Plot the test images from 'test_list', their predicted labels, and the true labels.
# Color correct predictions in green and incorrect predictions in red.
test_list= [16, 17, 22, 23, 24, 25, 39, 40, 41, 42, 48, 49, 50, 51]
num_rows = 7
num_cols = 2
num_images = num_rows * num_cols
#plt.figure(figsize=(2*2*num_cols, 2*num_rows))
plt.figure(figsize=(10,14))
for i in range(num_images):
@satishgunjal
satishgunjal / gist:552dd51ef372e48def926877c156ea11
Created October 17, 2020 07:52
plot the results for verification
i = 12
plt.figure(figsize=(12,6))
plt.subplot(1,2,1)
plot_image(i, predictions[i], test_labels, test_images)
plt.subplot(1,2,2)
plot_value_array(i, predictions[i], test_labels)
_ = plt.xticks(range(10), class_names, rotation=45)
plt.show()
def plot_value_array(i, predictions_array, true_label):
"""
This method will plot the percentage confidence score of each class prediction.
Input:
i: Index of the prediction to test
predictions_array: Every prediction contain array of 10 number
true_label: Correct image labels. In case of test data they are test_labels
"""
true_label = true_label[i]
def plot_image(i, predictions_array, true_label, img):
"""
This method will plot the true image and also compare the prediction with true values if matcing write the caption in green color else in red color.
Format is : predicted class %confidence score (true class)
Input:
i: Index of the prediction to test
predictions_array: Every prediction contain array of 10 number
true_label: Correct image labels. In case of test data they are test_labels
img: Test images. In case of test data they are test_images.
test_labels[0]
np.argmax(predictions[0])