import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df=pd.read_csv(“handwritten/mnist_train.csv”)
data= df.values
np.random.shuffle(data)
#print(data.shape)
x=data[:,1:]
y=data[: ,0]
#print(x.shape,y.shape)
#try to visualize in one image
def drawImg(x,y,i):
plt.imshow(x[i].reshape(28,28),cmap=‘gray’)
plt.title(“Label”+str(y[i]))
plt.show()
#for i in range(5):
drawImg(x,y,i)
split = int(0.80*x.shape[0])
x_train,y_train=x[:split,:],y[:split]
x_test, y_test = x[split:, :], y[split:]
#print(x_train.shape,y_train.shape)
#print(x_test.shape,y_test.shape)
#subplot 2 row 3 column
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.imshow(x_train[i].reshape(28,28),cmap=‘gray’)
plt.title(y_train[i])
plt.axis("off")
plt.show()