<jupyter_start><jupyter_text>Model Building<jupyter_code>model = tf.keras.models.Sequential()

model.add(tf.keras.layers.Dense(784, activation = tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation = tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation = tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation = tf.nn.relu))

model.add(tf.keras.layers.Dense(10, activation = tf.nn.softmax))

model.compile(optimizer = 'adam', loss = 'sparse_categorical_crossentropy', metrics = ['accuracy'])
# model.fit(train_X.to_numpy(), train_y.to_numpy(), epochs=10)<jupyter_output><empty_output><jupyter_text>Evaluation<jupyter_code>cross_y = cross_data['label']
cross_X = cross_data.drop(['label'], axis = 1)
# val_loss, val_acc = model.evaluate(cross_X.to_numpy(), cross_y.to_numpy()) # for 10 epochs -> 63% accuracy
model.fit(train_X.to_numpy(), train_y.to_numpy(), epochs=3)
val_loss, val_acc = model.evaluate(cross_X.to_numpy(), cross_y.to_numpy()) # for 3 epochs -> 63% accuracy
model.save('kannada_mnist.model')
plt.imshow(np.array(cross_X.iloc[0]).reshape(28,28), cmap= plt.cm.binary)
cross_predictions = model.predict([cross_X.to_numpy()])
np.argmax(cross_predictions[0])
cross_y[0]<jupyter_output><empty_output><jupyter_text>Test prediction<jupyter_code>test_data.head(3)
test_data.shape
test_label = test_data['id']
test_data = test_data.drop(['id'], axis =1)
test_data.head(3)
test_predictions = model.predict([test_data.to_numpy()])
test_label.head(3)
test_predictions_final = []
for i in range(0, len(test_predictions)):
    test_predictions_final.append(np.argmax(test_predictions[i]))
test_predictions_final[2:5]
final_predictions = pd.DataFrame(
    {
        'id' : test_label,
        'label': test_predictions_final
    })
final_predictions.head(3)
final_predictions.to_csv("result.csv", index = False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15995705850778313, 'fraction_numerical': 0.02147074610842727, 'mean_word_length': 7.247787610619469, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '199604', 'license': 'Apache-2.0', 'n_tokens_mistral': 754, 'n_tokens_neox': 724, 'n_words': 91, 'path': 'Kannada MNIST.ipynb', 'repo_name': 'Nibba2018/Kannada-MNIST', 'size': '1863'}