{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd \nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport tensorflow as tf\nimport random","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:08.122057Z","start_time":"2021-09-16T06:47:08.108053Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:42.995729Z","iopub.execute_input":"2021-10-05T08:06:42.996000Z","iopub.status.idle":"2021-10-05T08:06:43.001597Z","shell.execute_reply.started":"2021-10-05T08:06:42.995971Z","shell.execute_reply":"2021-10-05T08:06:43.000895Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = pd.read_csv(\"../input/Kannada-MNIST/train.csv\")\ntest_data = pd.read_csv(\"../input/Kannada-MNIST/test.csv\")\nDig_MNIST = pd.read_csv(\"../input/Kannada-MNIST/Dig-MNIST.csv\")","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:09.931464Z","start_time":"2021-09-16T06:47:08.123057Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:43.003459Z","iopub.execute_input":"2021-10-05T08:06:43.003903Z","iopub.status.idle":"2021-10-05T08:06:47.545689Z","shell.execute_reply.started":"2021-10-05T08:06:43.003870Z","shell.execute_reply":"2021-10-05T08:06:47.544702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.head()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:09.946467Z","start_time":"2021-09-16T06:47:09.932466Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.547471Z","iopub.execute_input":"2021-10-05T08:06:47.547759Z","iopub.status.idle":"2021-10-05T08:06:47.566889Z","shell.execute_reply.started":"2021-10-05T08:06:47.547723Z","shell.execute_reply":"2021-10-05T08:06:47.566194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train_data)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:09.961471Z","start_time":"2021-09-16T06:47:09.947468Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.568222Z","iopub.execute_input":"2021-10-05T08:06:47.568640Z","iopub.status.idle":"2021-10-05T08:06:47.581148Z","shell.execute_reply.started":"2021-10-05T08:06:47.568603Z","shell.execute_reply":"2021-10-05T08:06:47.580393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.head()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:09.977475Z","start_time":"2021-09-16T06:47:09.962472Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.584840Z","iopub.execute_input":"2021-10-05T08:06:47.585150Z","iopub.status.idle":"2021-10-05T08:06:47.603541Z","shell.execute_reply.started":"2021-10-05T08:06:47.585120Z","shell.execute_reply":"2021-10-05T08:06:47.602774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(test_data)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:09.993479Z","start_time":"2021-09-16T06:47:09.978476Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.605000Z","iopub.execute_input":"2021-10-05T08:06:47.605397Z","iopub.status.idle":"2021-10-05T08:06:47.612894Z","shell.execute_reply.started":"2021-10-05T08:06:47.605348Z","shell.execute_reply":"2021-10-05T08:06:47.611995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data[\"label\"].unique()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.039489Z","start_time":"2021-09-16T06:47:10.025486Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.614943Z","iopub.execute_input":"2021-10-05T08:06:47.615429Z","iopub.status.idle":"2021-10-05T08:06:47.623822Z","shell.execute_reply.started":"2021-10-05T08:06:47.615391Z","shell.execute_reply":"2021-10-05T08:06:47.622783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Check whether data is balanced or not","metadata":{}},{"cell_type":"code","source":"total = 0\ncounter_dict = {0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0}\n\nfor i in train_data[\"label\"]:\n    counter_dict[i]+=1\nprint(counter_dict)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.055493Z","start_time":"2021-09-16T06:47:10.04149Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.625508Z","iopub.execute_input":"2021-10-05T08:06:47.625784Z","iopub.status.idle":"2021-10-05T08:06:47.651406Z","shell.execute_reply.started":"2021-10-05T08:06:47.625750Z","shell.execute_reply":"2021-10-05T08:06:47.650575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Exploration","metadata":{}},{"cell_type":"code","source":"X = train_data.iloc[:, 1:].values\ny = train_data.iloc[:, 0].values","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.071496Z","start_time":"2021-09-16T06:47:10.056493Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.652731Z","iopub.execute_input":"2021-10-05T08:06:47.653222Z","iopub.status.idle":"2021-10-05T08:06:47.658226Z","shell.execute_reply.started":"2021-10-05T08:06:47.653182Z","shell.execute_reply":"2021-10-05T08:06:47.657301Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.087499Z","start_time":"2021-09-16T06:47:10.072497Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.659818Z","iopub.execute_input":"2021-10-05T08:06:47.660166Z","iopub.status.idle":"2021-10-05T08:06:47.669931Z","shell.execute_reply.started":"2021-10-05T08:06:47.660129Z","shell.execute_reply":"2021-10-05T08:06:47.668925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.shape","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.103503Z","start_time":"2021-09-16T06:47:10.0885Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.674220Z","iopub.execute_input":"2021-10-05T08:06:47.674420Z","iopub.status.idle":"2021-10-05T08:06:47.680854Z","shell.execute_reply.started":"2021-10-05T08:06:47.674396Z","shell.execute_reply":"2021-10-05T08:06:47.680029Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = X.reshape((X.shape[0], 28, 28, 1))\nX.shape","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.118506Z","start_time":"2021-09-16T06:47:10.104504Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.682449Z","iopub.execute_input":"2021-10-05T08:06:47.682875Z","iopub.status.idle":"2021-10-05T08:06:47.690565Z","shell.execute_reply.started":"2021-10-05T08:06:47.682838Z","shell.execute_reply":"2021-10-05T08:06:47.689644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.13451Z","start_time":"2021-09-16T06:47:10.119506Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.692267Z","iopub.execute_input":"2021-10-05T08:06:47.692561Z","iopub.status.idle":"2021-10-05T08:06:47.700789Z","shell.execute_reply.started":"2021-10-05T08:06:47.692523Z","shell.execute_reply":"2021-10-05T08:06:47.699773Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = tf.keras.utils.to_categorical(y, num_classes=10)\ny.shape","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.149514Z","start_time":"2021-09-16T06:47:10.135511Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.702632Z","iopub.execute_input":"2021-10-05T08:06:47.702907Z","iopub.status.idle":"2021-10-05T08:06:47.711766Z","shell.execute_reply.started":"2021-10-05T08:06:47.702872Z","shell.execute_reply":"2021-10-05T08:06:47.710710Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.165517Z","start_time":"2021-09-16T06:47:10.150514Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.713772Z","iopub.execute_input":"2021-10-05T08:06:47.714177Z","iopub.status.idle":"2021-10-05T08:06:47.722079Z","shell.execute_reply.started":"2021-10-05T08:06:47.714140Z","shell.execute_reply":"2021-10-05T08:06:47.721101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nX_train, X_valid, Y_train, Y_valid = train_test_split(X, y, test_size = 0.2, random_state=42) ","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.545602Z","start_time":"2021-09-16T06:47:10.166518Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:47.723842Z","iopub.execute_input":"2021-10-05T08:06:47.724554Z","iopub.status.idle":"2021-10-05T08:06:48.268915Z","shell.execute_reply.started":"2021-10-05T08:06:47.724514Z","shell.execute_reply":"2021-10-05T08:06:48.268142Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_random_digit():\n    random_index = np.random.randint(0, X_train.shape[0])\n    plt.figure(figsize=(2,2))\n    plt.imshow(X_train[random_index], cmap=\"gray\")\n    plt.title(np.argmax(y[random_index]))\n    plt.axis(\"Off\")\n    plt.show()  \nplot_random_digit()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:10.57761Z","start_time":"2021-09-16T06:47:10.546603Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:48.270304Z","iopub.execute_input":"2021-10-05T08:06:48.270576Z","iopub.status.idle":"2021-10-05T08:06:48.346854Z","shell.execute_reply.started":"2021-10-05T08:06:48.270539Z","shell.execute_reply":"2021-10-05T08:06:48.345997Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12, 8), dpi=200)\nfor i in range(50):\n    plt.subplot(5, 10, i+1)\n    index = np.random.randint(0, X_train.shape[0])\n    plt.imshow(X_train[index], cmap=\"gray\")\n    plt.title(np.argmax(y[index]))\n    plt.axis('off')","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:11.625844Z","start_time":"2021-09-16T06:47:10.57861Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:48.348235Z","iopub.execute_input":"2021-10-05T08:06:48.353356Z","iopub.status.idle":"2021-10-05T08:06:50.772785Z","shell.execute_reply.started":"2021-10-05T08:06:48.353304Z","shell.execute_reply":"2021-10-05T08:06:50.772098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learning_rate=0.001\nbatch_size = 32\nepochs = 30\nsteps_per_epoch = 100\nvalidation_steps = 50","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:11.641849Z","start_time":"2021-09-16T06:47:11.626845Z"},"execution":{"iopub.status.busy":"2021-10-05T08:06:50.774122Z","iopub.execute_input":"2021-10-05T08:06:50.774517Z","iopub.status.idle":"2021-10-05T08:06:50.778791Z","shell.execute_reply.started":"2021-10-05T08:06:50.774481Z","shell.execute_reply":"2021-10-05T08:06:50.778148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom tensorflow.keras.losses import categorical_crossentropy\nfrom tensorflow.keras.optimizers import Adam\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Activation,BatchNormalization,Conv2D,Dense,Dropout,Flatten,MaxPooling2D\n\n# Set the seed\ntf.random.set_seed(42)\n\n# Preprocess data (get all of the pixel values between 1 and 0, also called scaling/normalization)\ntrain_datagen = ImageDataGenerator(rescale=1./255)\nvalid_datagen = ImageDataGenerator(rescale=1./255)\n\ntrain_data = train_datagen.flow(X_train,Y_train,batch_size=batch_size)\nvalid_data = valid_datagen.flow(X_valid,Y_valid)\n\n# Create a CNN model (same as Tiny VGG - https://poloclub.github.io/cnn-explainer/)\nmodel_1 = tf.keras.models.Sequential([\n    Conv2D(64, 3, padding='same', input_shape=(28, 28, 1)),\n    BatchNormalization(scale=False, center=True),\n    Activation('relu'),\n    Conv2D(64, 3, padding='same'),\n    BatchNormalization(scale=False, center=True),\n    Activation('relu'),\n    MaxPooling2D(2,2),\n    Dropout(0.2),\n\n    Conv2D(128, 3, padding='same'),\n    BatchNormalization(scale=False, center=True),\n    Activation('relu'),\n    Conv2D(128, 3, padding='same'),\n    BatchNormalization(scale=False, center=True),\n    Activation('relu'),\n    MaxPooling2D(2,2),\n    Dropout(0.2),\n    \n    Flatten(),\n    Dense(512),\n    BatchNormalization(scale=False, center=True),\n    Activation('relu'),\n    Dense(128),\n    BatchNormalization(scale=False, center=True),\n    Activation('relu'),\n    Dense(10, activation='softmax')\n])\n\n# Compile the model\nmodel_1.compile(loss=tf.keras.losses.binary_crossentropy,\n                optimizer=tf.keras.optimizers.Adam(),\n                metrics=[\"accuracy\"])\n\n\n# Fit the model\n\nhistory = model_1.fit(\n      train_data,\n      steps_per_epoch=steps_per_epoch,\n      epochs=epochs,\n      validation_data=valid_data,\n      validation_steps=validation_steps)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:58.411336Z","start_time":"2021-09-16T06:47:11.642849Z"},"run_control":{"marked":false},"execution":{"iopub.status.busy":"2021-10-05T08:06:50.780111Z","iopub.execute_input":"2021-10-05T08:06:50.780507Z","iopub.status.idle":"2021-10-05T08:07:21.289128Z","shell.execute_reply.started":"2021-10-05T08:06:50.780468Z","shell.execute_reply":"2021-10-05T08:07:21.288333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_1.summary()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:58.427341Z","start_time":"2021-09-16T06:47:58.413336Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:21.290853Z","iopub.execute_input":"2021-10-05T08:07:21.291156Z","iopub.status.idle":"2021-10-05T08:07:21.308691Z","shell.execute_reply.started":"2021-10-05T08:07:21.291120Z","shell.execute_reply":"2021-10-05T08:07:21.307801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plot the validation and training data separately\ndef plot_loss_curves(history):\n    \"\"\"\n    Returns separate loss curves for training and validation metrics.\n    \"\"\"\n    loss = history.history['loss']\n    val_loss = history.history['val_loss']\n\n    accuracy = history.history['accuracy']\n    val_accuracy = history.history['val_accuracy']\n\n    epochs = range(len(history.history['loss']))\n\n    # Plot loss\n    plt.plot(epochs, loss, label='training_loss')\n    plt.plot(epochs, val_loss, label='val_loss')\n    plt.title('Loss')\n    plt.xlabel('Epochs')\n    plt.legend()\n\n    # Plot accuracy\n    plt.figure()\n    plt.plot(epochs, accuracy, label='training_accuracy')\n    plt.plot(epochs, val_accuracy, label='val_accuracy')\n    plt.title('Accuracy')\n    plt.xlabel('Epochs')\n    plt.legend()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:58.443343Z","start_time":"2021-09-16T06:47:58.430341Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:21.311595Z","iopub.execute_input":"2021-10-05T08:07:21.311814Z","iopub.status.idle":"2021-10-05T08:07:21.320948Z","shell.execute_reply.started":"2021-10-05T08:07:21.311788Z","shell.execute_reply":"2021-10-05T08:07:21.319956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_loss_curves(history)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:58.633386Z","start_time":"2021-09-16T06:47:58.444343Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:21.322540Z","iopub.execute_input":"2021-10-05T08:07:21.322976Z","iopub.status.idle":"2021-10-05T08:07:21.800038Z","shell.execute_reply.started":"2021-10-05T08:07:21.322935Z","shell.execute_reply":"2021-10-05T08:07:21.799312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total = 0\ncounter_dict = {0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0}\n\nfor i in Dig_MNIST[\"label\"]:\n    counter_dict[i]+=1\nprint(counter_dict)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:58.64939Z","start_time":"2021-09-16T06:47:58.634387Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:21.801324Z","iopub.execute_input":"2021-10-05T08:07:21.801813Z","iopub.status.idle":"2021-10-05T08:07:21.811664Z","shell.execute_reply.started":"2021-10-05T08:07:21.801771Z","shell.execute_reply":"2021-10-05T08:07:21.810790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# X_extra = extra_data.iloc[:, 1:].values\n# X_extra = X_extra.reshape((X_extra.shape[0],28,28,1))\n# X_extra.shape\nx_dig=Dig_MNIST.drop('label',axis=1).iloc[:,:].values\nx_dig = x_dig.reshape(x_dig.shape[0], 28, 28,1)\nprint(f\"x_dig shape: {x_dig.shape}\")","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:58.680397Z","start_time":"2021-09-16T06:47:58.650391Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:21.813284Z","iopub.execute_input":"2021-10-05T08:07:21.813974Z","iopub.status.idle":"2021-10-05T08:07:21.839792Z","shell.execute_reply.started":"2021-10-05T08:07:21.813924Z","shell.execute_reply":"2021-10-05T08:07:21.838970Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# y_extra = extra_data.label\n# y_extra.shape\ny_dig=Dig_MNIST.label\nprint(f\"y_dig shape: {y_dig.shape}\")","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:58.6964Z","start_time":"2021-09-16T06:47:58.681397Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:21.841234Z","iopub.execute_input":"2021-10-05T08:07:21.841658Z","iopub.status.idle":"2021-10-05T08:07:21.847652Z","shell.execute_reply.started":"2021-10-05T08:07:21.841620Z","shell.execute_reply":"2021-10-05T08:07:21.846651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_dig = model_1.predict(x_dig/255)\npreds_dig = preds_dig.argmax(axis=1)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:59.422563Z","start_time":"2021-09-16T06:47:58.6974Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:21.849239Z","iopub.execute_input":"2021-10-05T08:07:21.849835Z","iopub.status.idle":"2021-10-05T08:07:22.519710Z","shell.execute_reply.started":"2021-10-05T08:07:21.849793Z","shell.execute_reply":"2021-10-05T08:07:22.518903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix\ncm = confusion_matrix(y_dig, preds_dig)\nimport seaborn as sns\nplt.figure(figsize=[7,6])\nsns.heatmap(cm, cmap=\"Reds\", annot=True, fmt='.0f')\nplt.show()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:59.690623Z","start_time":"2021-09-16T06:47:59.423564Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:22.521141Z","iopub.execute_input":"2021-10-05T08:07:22.521433Z","iopub.status.idle":"2021-10-05T08:07:23.145023Z","shell.execute_reply.started":"2021-10-05T08:07:22.521400Z","shell.execute_reply":"2021-10-05T08:07:23.144326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import classification_report\nprint(classification_report(y_dig, preds_dig))","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:59.706627Z","start_time":"2021-09-16T06:47:59.691624Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:23.148770Z","iopub.execute_input":"2021-10-05T08:07:23.148982Z","iopub.status.idle":"2021-10-05T08:07:23.175415Z","shell.execute_reply.started":"2021-10-05T08:07:23.148957Z","shell.execute_reply":"2021-10-05T08:07:23.174682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission = pd.read_csv(\"../input/Kannada-MNIST/sample_submission.csv\")","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:59.722631Z","start_time":"2021-09-16T06:47:59.707628Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:23.176758Z","iopub.execute_input":"2021-10-05T08:07:23.177142Z","iopub.status.idle":"2021-10-05T08:07:23.186138Z","shell.execute_reply.started":"2021-10-05T08:07:23.177106Z","shell.execute_reply":"2021-10-05T08:07:23.185294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_test=test_data.drop('id', axis=1).iloc[:,:].values\nx_test = x_test.reshape(x_test.shape[0], 28, 28,1)\nprint(f\"x_test shape: {x_test.shape}\")","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:47:59.737634Z","start_time":"2021-09-16T06:47:59.72363Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:23.187878Z","iopub.execute_input":"2021-10-05T08:07:23.188413Z","iopub.status.idle":"2021-10-05T08:07:23.203979Z","shell.execute_reply.started":"2021-10-05T08:07:23.188374Z","shell.execute_reply":"2021-10-05T08:07:23.203229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = model_1.predict(x_test)\npredictions = predictions.argmax(axis=1)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:48:00.15773Z","start_time":"2021-09-16T06:47:59.738634Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:23.205698Z","iopub.execute_input":"2021-10-05T08:07:23.206141Z","iopub.status.idle":"2021-10-05T08:07:23.634702Z","shell.execute_reply.started":"2021-10-05T08:07:23.206102Z","shell.execute_reply":"2021-10-05T08:07:23.633835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission[\"label\"] = predictions","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:48:00.173731Z","start_time":"2021-09-16T06:48:00.158729Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:23.635887Z","iopub.execute_input":"2021-10-05T08:07:23.636929Z","iopub.status.idle":"2021-10-05T08:07:23.644502Z","shell.execute_reply.started":"2021-10-05T08:07:23.636900Z","shell.execute_reply":"2021-10-05T08:07:23.643725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.head()","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:48:00.189735Z","start_time":"2021-09-16T06:48:00.174732Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:23.645855Z","iopub.execute_input":"2021-10-05T08:07:23.646653Z","iopub.status.idle":"2021-10-05T08:07:23.657726Z","shell.execute_reply.started":"2021-10-05T08:07:23.646595Z","shell.execute_reply":"2021-10-05T08:07:23.656671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.to_csv(\"submission.csv\",index=False)","metadata":{"ExecuteTime":{"end_time":"2021-09-16T06:48:00.20574Z","start_time":"2021-09-16T06:48:00.190736Z"},"execution":{"iopub.status.busy":"2021-10-05T08:07:23.659322Z","iopub.execute_input":"2021-10-05T08:07:23.659829Z","iopub.status.idle":"2021-10-05T08:07:23.675202Z","shell.execute_reply.started":"2021-10-05T08:07:23.659793Z","shell.execute_reply":"2021-10-05T08:07:23.674528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}