Skip to content

Instantly share code, notes, and snippets.

@BinarySpoon
Created January 11, 2021 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BinarySpoon/886d2c633c1d72a4485839c3f621d78f to your computer and use it in GitHub Desktop.
Save BinarySpoon/886d2c633c1d72a4485839c3f621d78f to your computer and use it in GitHub Desktop.
# Importing Data -->
digits = load_digits()
# Display Number Of Images -->
print("Image data shape: ", digits.data.shape)
print()
print("Label data shape: ", digits.target.shape)
# Show images -->
plt.figure(figsize=(20,8))
for index, (image, label) in enumerate(zip(digits.data[0:16], digits.target[0:16])):
plt.subplot(2,8, index+1)
plt.imshow(np.reshape(image,(8,8)), cmap=plt.cm.gray)
plt.title('Labeled %i\n' % label, fontsize = 20)
'''
1. create a blank fig.
2. run a loop calling the first 16 entries in digits.data, digits.target as "image" and "label" respectively.
3. create a subplot inside the blank figure of 2 rows and 8 cols.
4. place images in them (8,8) long and gray.
Algo credit: 'https://towardsdatascience.com/logistic-regression-using-python-sklearn-numpy-mnist-handwriting-recognition-matplotlib-a6b31e2b166a'
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment