<jupyter_start><jupyter_text>Importing the Datasets<jupyter_code>path_to_file_train="/media/vipul/Local Disk (D:)/Data Science and ML/DATA/mnist_train.csv"
path_to_file_test="/media/vipul/Local Disk (D:)/Data Science and ML/DATA/mnist_test.csv"
train_dataset=pd.read_csv(path_to_file_train)
test_dataset=pd.read_csv(path_to_file_test)
Y_train=train_dataset["label"]
train_dataset = train_dataset.drop(labels = ["label"],axis = 1)
#g=sns.countplot(Y_train)
Y_train.value_counts()
plt.hist(Y_train)
train_dataset.isnull().any().describe()
test_dataset.isnull().any().describe()<jupyter_output><empty_output><jupyter_text>Normalising grayscale normalization to reduce the effect of illumination's differences CNN converg faster on [0..1] data than on [0..255]<jupyter_code>train_dataset=train_dataset/255.0
test_dataset=train_dataset/255.0<jupyter_output><empty_output><jupyter_text>Reshape<jupyter_code>train_dataset=train_dataset.values.reshape(-1,28,28,1)
test_dataset=test_dataset.values.reshape(-1,28,28,1)<jupyter_output><empty_output><jupyter_text>One Hot Encoding<jupyter_code>Y_train=to_categorical(Y_train,num_classes=10)
g = plt.imshow(train_dataset[10000][:,:,0])<jupyter_output><empty_output><jupyter_text>Splitting the Dataset into training and test<jupyter_code>x_train,x_test,y_train,y_test=train_test_split(train_dataset,Y_train,test_size=0.1,random_state=2)<jupyter_output><empty_output><jupyter_text>Creating the Convolutional network<jupyter_code>classifier=Sequential()
classifier.add(Convolution2D(32,3,3,input_shape=(28,28,1),activation='relu'))
classifier.add(MaxPooling2D(pool_size=(2,2)))
classifier.add(Flatten())
classifier.add(Dense(output_dim=128,activation='relu'))
classifier.add(Dense(output_dim=10,activation='sigmoid'))
classifier.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])<jupyter_output>/home/vipul/anaconda3/lib/python3.5/site-packages/ipykernel/__main__.py:2: UserWarning: Update your `Conv2D` call to the Keras 2 API: `Conv2D(32, (3, 3), activation="relu", input_shape=(28, 28, 1...)`
  from ipykernel import kernelapp as app
/home/vipul/anaconda3/lib/python3.5/site-packages/ipykernel/__main__.py:5: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(units=128, activation="relu")`
/home/vipul/anaconda3/lib/python3.5/site-packages/ipykernel/__main__.py:6: UserWarning: Update your `Dense` call to the Keras 2 API: `Dense(units=10, activation="sigmoid")`<jupyter_text>Fitting the CNN To the Images<jupyter_code>#train_datagen=ImageDataGenerator(rescale=1./255,shear_range=0.2,zoom_range=0.2,horizontal_flip=True)
#test_datagen=ImageDataGenerator(rescale=1./255)

classifier.fit(x_train,y_train,validation_data=(x_test,y_test),epochs=10,batch_size=32,verbose=2)<jupyter_output>Train on 54000 samples, validate on 6000 samples
Epoch 1/10
 - 70s - loss: 0.0388 - acc: 0.9873 - val_loss: 0.0179 - val_acc: 0.9945
Epoch 2/10
 - 55s - loss: 0.0132 - acc: 0.9958 - val_loss: 0.0131 - val_acc: 0.9956
Epoch 3/10
 - 55s - loss: 0.0092 - acc: 0.9970 - val_loss: 0.0100 - val_acc: 0.9965
Epoch 4/10
 - 60s - loss: 0.0068 - acc: 0.9978 - val_loss: 0.0106 - val_acc: 0.9965
Epoch 5/10
 - 56s - loss: 0.0049 - acc: 0.9985 - val_loss: 0.0090 - val_acc: 0.9970
Epoch 6/10
 - 56s - loss: 0.0036 - acc: 0.9988 - val_loss: 0.0092 - val_acc: 0.9972
Epoch 7/10
 - 56s - loss: 0.0025 - acc: 0.9992 - val_loss: 0.0094 - val_acc: 0.9970
Epoch 8/10
 - 55s - loss: 0.0020 - acc: 0.9993 - val_loss: 0.0107 - val_acc: 0.9967
Epoch 9/10
 - 57s - loss: 0.0015 - acc: 0.9995 - val_loss: 0.0105 - val_acc: 0.9972
Epoch 10/10
 - 56s - loss: 0.0012 - acc: 0.9996 - val_loss: 0.0102 - val_acc: 0.9973
{'fraction_non_alphanumeric': 0.14583333333333334, 'fraction_numerical': 0.09978070175438597, 'mean_word_length': 6.356854838709677, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '311085', 'license': 'MIT', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1480, 'n_words': 238, 'path': 'MNIST_notebook.ipynb', 'repo_name': '4322vipul/MNIST_Data_Classifier', 'size': '3648'}