This is the code that i am using to print the original unreduced picture of 100 mnist data but is is constantly giving me an error. Even after trying a lot I could not find the solution. Request for suggestion
from sklearn.datasets import fetch_openml
mnist = fetch_openml('mnist_784')
X = mnist["data"]
y = mnist["target"]
X_train, X_test, y_train, y_test = X[:60000], X[60000:], y[:60000],y[60000:]
pca = PCA()
pca.fit(X_train)
cumsum = np.cumsum(pca.explained_variance_ratio_)
d = np.argmax(cumsum >= 0.90) + 1
#Setup a figure 8 inches by 8 inches
fig = plt.figure(figsize=(8,8))
fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.05, wspace=0.05)
for i in range(100):
ax = fig.add_subplot(10, 10, i+1, xticks=[], yticks=[])
ax.imshow(X_train[i].reshape(28,28), cmap=plt.cm.bone, interpolation='nearest')
plt.show()