<jupyter_start><jupyter_text>If you are using Google colab, then only will you need to run the above 3 cells, and change the path accordingly, else you can start your code from here<jupyter_code>import numpy as np 
import pandas as pd
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.keras import layers, models
from sklearn.model_selection import train_test_split

from tensorflow.keras.preprocessing import image
from tensorflow.keras.preprocessing.image import ImageDataGenerator
train_data = pd.read_csv("./data/train.csv")
train_label = train_data.pop('label')

test_data = pd.read_csv("./data/test.csv")
test_label=test_data.pop('Label')
train_label.value_counts().plot.bar()
test_label.value_counts().plot.bar()
print(train_data.shape)
train_data = train_data.values.reshape(train_data.shape[0], 28, 28)
train_data = train_data / 255.0
print(test_data.shape)
test_data = test_data.values.reshape(test_data.shape[0], 28,28)
test_data = test_data / 255.0
fig = plt.figure(figsize=(6,8))
for i in range(1, 10):
    fig.add_subplot(3,3,i)
    plt.imshow(train_data[i],cmap='gray')
    plt.grid(False)
    plt.title(train_label[i])
model = tf.keras.Sequential([
    tf.keras.layers.Flatten(input_shape=(28,28)),
    tf.keras.layers.Dense(128, activation = "relu"),
    tf.keras.layers.Dense(10, activation = "softmax")
])
model.compile(optimizer = "adam", loss = tf.losses.sparse_categorical_crossentropy, metrics = ['accuracy'])
trainer = model.fit(train_data, train_label, epochs = 10)
def plot_training(history):
    fig, axs = plt.subplots(1,2,figsize=(16,5)) 
    axs[0].plot(history.history['accuracy'], 'c') 
    axs[0].set_title('Model Accuracy') 
    axs[0].set_ylabel('Accuracy') 
    axs[0].set_xlabel('Epoch') 
    axs[0].legend(['train', 'validate'], loc='upper left') 
    
    axs[1].plot(history.history['loss'], 'c') 
    axs[1].set_title('Model Loss') 
    axs[1].set_ylabel('Loss') 
    axs[1].set_xlabel('Epoch') 
    axs[1].legend(['train', 'validate'], loc='upper right') 
    plt.show()
print(trainer.history)
plot_training(trainer)
test_result = model.predict_classes(test_data)
fig = plt.figure(figsize=(6,8))
for i in range(1, 10):
    image = test_data[i+10]
    label = test_result[i+10]
    fig.add_subplot(3,3,i)
    plt.imshow(image,cmap='gray')
    plt.grid(False)
    plt.title(label)
score = model.evaluate(test_data, test_label, verbose = 0) 

print('Test loss:', score[0]) 
print('Test accuracy:', score[1])<jupyter_output>Test loss: 0.09790273755788803
Test accuracy: 0.9741071462631226
{'fraction_non_alphanumeric': 0.14992150706436422, 'fraction_numerical': 0.039638932496075356, 'mean_word_length': 5.247549019607843, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '252470', 'license': 'Apache-2.0', 'n_tokens_mistral': 1003, 'n_tokens_neox': 933, 'n_words': 178, 'path': 'Digit-classifier/Digit_classification.ipynb', 'repo_name': 'nikjohn7/Introductory-ML-projects', 'size': '2548'}