{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-07-05T07:58:53.513967Z","iopub.execute_input":"2021-07-05T07:58:53.514359Z","iopub.status.idle":"2021-07-05T07:58:53.526593Z","shell.execute_reply.started":"2021-07-05T07:58:53.514253Z","shell.execute_reply":"2021-07-05T07:58:53.525580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport tensorflow as tf\nfrom sklearn.model_selection import train_test_split\nimport keras\nfrom tensorflow.keras.optimizers import RMSprop\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom keras.layers import LeakyReLU\nfrom keras.layers.normalization import BatchNormalization\nfrom tensorflow.keras.callbacks import LearningRateScheduler\nfrom tensorflow.keras.callbacks import EarlyStopping\n\nimport matplotlib.pyplot as plt ","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:58:53.528608Z","iopub.execute_input":"2021-07-05T07:58:53.529384Z","iopub.status.idle":"2021-07-05T07:58:59.026748Z","shell.execute_reply.started":"2021-07-05T07:58:53.529346Z","shell.execute_reply":"2021-07-05T07:58:59.025900Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')\ntest = pd.read_csv(\"/kaggle/input/Kannada-MNIST/test.csv\")\nDig_MNIST = pd.read_csv(\"/kaggle/input/Kannada-MNIST/Dig-MNIST.csv\")\nsample_sub = pd.read_csv(\"/kaggle/input/Kannada-MNIST/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:58:59.028154Z","iopub.execute_input":"2021-07-05T07:58:59.028656Z","iopub.status.idle":"2021-07-05T07:59:04.318068Z","shell.execute_reply.started":"2021-07-05T07:58:59.028613Z","shell.execute_reply":"2021-07-05T07:59:04.317090Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Train data shape: \", train.shape)\nprint(\"Test data shape: \", test.shape)\nprint(\"Dig MNIST data shape: \", Dig_MNIST.shape)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.319531Z","iopub.execute_input":"2021-07-05T07:59:04.320113Z","iopub.status.idle":"2021-07-05T07:59:04.327008Z","shell.execute_reply.started":"2021-07-05T07:59:04.320074Z","shell.execute_reply":"2021-07-05T07:59:04.326106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.330942Z","iopub.execute_input":"2021-07-05T07:59:04.331654Z","iopub.status.idle":"2021-07-05T07:59:04.374733Z","shell.execute_reply.started":"2021-07-05T07:59:04.331616Z","shell.execute_reply":"2021-07-05T07:59:04.374055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We are splitting whole dataframe into X and y with 1st column as y as it is label and remaining columns as X","metadata":{}},{"cell_type":"code","source":"X=train.iloc[:,1:].values \nY=train.iloc[:,0].values ","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.379526Z","iopub.execute_input":"2021-07-05T07:59:04.381419Z","iopub.status.idle":"2021-07-05T07:59:04.387389Z","shell.execute_reply.started":"2021-07-05T07:59:04.381383Z","shell.execute_reply":"2021-07-05T07:59:04.386558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y[:20]","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.391988Z","iopub.execute_input":"2021-07-05T07:59:04.394066Z","iopub.status.idle":"2021-07-05T07:59:04.403049Z","shell.execute_reply.started":"2021-07-05T07:59:04.394030Z","shell.execute_reply":"2021-07-05T07:59:04.402058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.407370Z","iopub.execute_input":"2021-07-05T07:59:04.409242Z","iopub.status.idle":"2021-07-05T07:59:04.417559Z","shell.execute_reply.started":"2021-07-05T07:59:04.409208Z","shell.execute_reply":"2021-07-05T07:59:04.416560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Now we are reshaping the data to make it appropriate for keras","metadata":{}},{"cell_type":"code","source":"X = X.reshape(X.shape[0], 28, 28,1) \nprint(X.shape)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.420188Z","iopub.execute_input":"2021-07-05T07:59:04.421716Z","iopub.status.idle":"2021-07-05T07:59:04.429216Z","shell.execute_reply.started":"2021-07-05T07:59:04.421680Z","shell.execute_reply":"2021-07-05T07:59:04.428277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"and converting the labels into categorical form","metadata":{}},{"cell_type":"code","source":"Y = keras.utils.to_categorical(Y, 10) \nprint(Y.shape)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.432003Z","iopub.execute_input":"2021-07-05T07:59:04.433708Z","iopub.status.idle":"2021-07-05T07:59:04.443681Z","shell.execute_reply.started":"2021-07-05T07:59:04.433672Z","shell.execute_reply":"2021-07-05T07:59:04.442641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Similarly, modifying test data too","metadata":{}},{"cell_type":"code","source":"test.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.446479Z","iopub.execute_input":"2021-07-05T07:59:04.447711Z","iopub.status.idle":"2021-07-05T07:59:04.479608Z","shell.execute_reply.started":"2021-07-05T07:59:04.447677Z","shell.execute_reply":"2021-07-05T07:59:04.478775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_test=test.drop('id', axis=1).iloc[:,:].values\nx_test = x_test.reshape(x_test.shape[0], 28, 28,1)\nx_test.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.480855Z","iopub.execute_input":"2021-07-05T07:59:04.481378Z","iopub.status.idle":"2021-07-05T07:59:04.497263Z","shell.execute_reply.started":"2021-07-05T07:59:04.481343Z","shell.execute_reply":"2021-07-05T07:59:04.496455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Dig_MNIST.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.498622Z","iopub.execute_input":"2021-07-05T07:59:04.499166Z","iopub.status.idle":"2021-07-05T07:59:04.523920Z","shell.execute_reply.started":"2021-07-05T07:59:04.499130Z","shell.execute_reply":"2021-07-05T07:59:04.523044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"same with dig_mnist too","metadata":{}},{"cell_type":"code","source":"x_dig=Dig_MNIST.drop('label',axis=1).iloc[:,:].values\nprint(x_dig.shape)\nx_dig = x_dig.reshape(x_dig.shape[0], 28, 28,1)\nx_dig.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.525217Z","iopub.execute_input":"2021-07-05T07:59:04.525543Z","iopub.status.idle":"2021-07-05T07:59:04.555244Z","shell.execute_reply.started":"2021-07-05T07:59:04.525509Z","shell.execute_reply":"2021-07-05T07:59:04.554567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_dig=Dig_MNIST.label\ny_dig.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.556409Z","iopub.execute_input":"2021-07-05T07:59:04.559499Z","iopub.status.idle":"2021-07-05T07:59:04.568608Z","shell.execute_reply.started":"2021-07-05T07:59:04.559453Z","shell.execute_reply":"2021-07-05T07:59:04.567587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Now, lets split the data into training and validation set","metadata":{}},{"cell_type":"code","source":"X_train, X_valid, Y_train, Y_valid = train_test_split(X, Y, test_size = 0.10, random_state=42) ","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:04.570626Z","iopub.execute_input":"2021-07-05T07:59:04.572104Z","iopub.status.idle":"2021-07-05T07:59:05.187328Z","shell.execute_reply.started":"2021-07-05T07:59:04.572065Z","shell.execute_reply":"2021-07-05T07:59:05.186528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Using keras augmentation to enrich data :P","metadata":{}},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(rescale = 1./255.,\n                                   rotation_range = 10,\n                                   width_shift_range = 0.25,\n                                   height_shift_range = 0.25,\n                                   shear_range = 0.1,\n                                   zoom_range = 0.25,\n                                   horizontal_flip = False)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:05.188763Z","iopub.execute_input":"2021-07-05T07:59:05.189128Z","iopub.status.idle":"2021-07-05T07:59:05.196136Z","shell.execute_reply.started":"2021-07-05T07:59:05.189090Z","shell.execute_reply":"2021-07-05T07:59:05.195065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"valid_datagen = ImageDataGenerator(rescale=1./255) \n","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:05.197723Z","iopub.execute_input":"2021-07-05T07:59:05.198126Z","iopub.status.idle":"2021-07-05T07:59:05.203408Z","shell.execute_reply.started":"2021-07-05T07:59:05.198091Z","shell.execute_reply":"2021-07-05T07:59:05.202474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Defining a callback function which will reduce the learning rate as training progresses","metadata":{}},{"cell_type":"code","source":"def lr_decay(epoch):#lrv\n    return initial_learningrate * 0.99 ** epoch","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:05.205000Z","iopub.execute_input":"2021-07-05T07:59:05.205525Z","iopub.status.idle":"2021-07-05T07:59:05.211323Z","shell.execute_reply.started":"2021-07-05T07:59:05.205489Z","shell.execute_reply":"2021-07-05T07:59:05.210389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = tf.keras.Sequential([\n    tf.keras.layers.Conv2D(64, (3,3), padding='same', input_shape=(28,28,1)),\n    tf.keras.layers.BatchNormalization(momentum=0.5, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.Conv2D(64, (3, 3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.MaxPooling2D(2,2),\n    tf.keras.layers.Dropout(0.2),\n    tf.keras.layers.Conv2D(128, (3, 3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.Conv2D(128, (3, 3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.MaxPooling2D(2, 2),\n    tf.keras.layers.Dropout(0.2),\n    tf.keras.layers.Conv2D(256, (3, 3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.Conv2D(256, (3, 3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.MaxPooling2D(2, 2),\n    tf.keras.layers.Dropout(0.2),\n    tf.keras.layers.Flatten(),\n    tf.keras.layers.Dense(256),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.BatchNormalization(),\n    tf.keras.layers.Dense(10, activation='softmax')\n])\n\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:05.212737Z","iopub.execute_input":"2021-07-05T07:59:05.213226Z","iopub.status.idle":"2021-07-05T07:59:07.684572Z","shell.execute_reply.started":"2021-07-05T07:59:05.213190Z","shell.execute_reply":"2021-07-05T07:59:07.683123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"initial_learningrate=2e-3\nbatch_size = 64\nepochs = 50\ninput_shape = (28, 28, 1)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:07.688221Z","iopub.execute_input":"2021-07-05T07:59:07.688492Z","iopub.status.idle":"2021-07-05T07:59:07.695808Z","shell.execute_reply.started":"2021-07-05T07:59:07.688466Z","shell.execute_reply":"2021-07-05T07:59:07.694165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"es = EarlyStopping(monitor='val_loss', verbose=1, patience=10)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:07.697355Z","iopub.execute_input":"2021-07-05T07:59:07.697843Z","iopub.status.idle":"2021-07-05T07:59:07.703869Z","shell.execute_reply.started":"2021-07-05T07:59:07.697792Z","shell.execute_reply":"2021-07-05T07:59:07.702366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(loss=\"categorical_crossentropy\",\n              optimizer=RMSprop(lr=initial_learningrate),\n              metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:07.705690Z","iopub.execute_input":"2021-07-05T07:59:07.706328Z","iopub.status.idle":"2021-07-05T07:59:07.727053Z","shell.execute_reply.started":"2021-07-05T07:59:07.706270Z","shell.execute_reply":"2021-07-05T07:59:07.726118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn import metrics","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:07.728240Z","iopub.execute_input":"2021-07-05T07:59:07.728636Z","iopub.status.idle":"2021-07-05T07:59:07.736022Z","shell.execute_reply.started":"2021-07-05T07:59:07.728599Z","shell.execute_reply":"2021-07-05T07:59:07.735268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit_generator(\n      train_datagen.flow(X_train,Y_train, batch_size=batch_size),\n      steps_per_epoch=100,\n      epochs=epochs,\n      callbacks=[LearningRateScheduler(lr_decay),\n                 es\n               ],\n      validation_data=valid_datagen.flow(X_valid,Y_valid),\n      validation_steps=50,  \n      verbose=2)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:59:07.737821Z","iopub.execute_input":"2021-07-05T07:59:07.738104Z","iopub.status.idle":"2021-07-05T08:00:42.889484Z","shell.execute_reply.started":"2021-07-05T07:59:07.738074Z","shell.execute_reply":"2021-07-05T08:00:42.888554Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_dig=model.predict_classes(x_dig/255)\nmetrics.accuracy_score(preds_dig, y_dig)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:00:42.893446Z","iopub.execute_input":"2021-07-05T08:00:42.894056Z","iopub.status.idle":"2021-07-05T08:00:43.685553Z","shell.execute_reply.started":"2021-07-05T08:00:42.894019Z","shell.execute_reply":"2021-07-05T08:00:43.684864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"keras.backend.clear_session()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:00:43.686976Z","iopub.execute_input":"2021-07-05T08:00:43.687317Z","iopub.status.idle":"2021-07-05T08:00:43.693827Z","shell.execute_reply.started":"2021-07-05T08:00:43.687268Z","shell.execute_reply":"2021-07-05T08:00:43.692924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = tf.keras.models.Sequential([\n    tf.keras.layers.Conv2D(64, (3,3), padding='same', input_shape=(28, 28, 1)),\n    tf.keras.layers.BatchNormalization(momentum=0.5, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.Conv2D(64,  (3,3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n\n    tf.keras.layers.MaxPooling2D(2, 2),\n    tf.keras.layers.Dropout(0.2),\n    \n    tf.keras.layers.Conv2D(128, (3,3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.Conv2D(128, (3,3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    \n    tf.keras.layers.MaxPooling2D(2,2),\n    tf.keras.layers.Dropout(0.2),    \n    \n    tf.keras.layers.Conv2D(256, (3,3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.2, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n    tf.keras.layers.Conv2D(256, (3,3), padding='same'),\n    tf.keras.layers.BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer=\"uniform\"),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n\n    \n    tf.keras.layers.MaxPooling2D(2,2),\n    tf.keras.layers.Dropout(0.2),\n    \n    \n    tf.keras.layers.Flatten(),\n    tf.keras.layers.Dense(256),\n    tf.keras.layers.LeakyReLU(alpha=0.1),\n\n    tf.keras.layers.BatchNormalization(),\n    tf.keras.layers.Dense(10, activation='softmax')\n])","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:00:43.695811Z","iopub.execute_input":"2021-07-05T08:00:43.696287Z","iopub.status.idle":"2021-07-05T08:00:43.867945Z","shell.execute_reply.started":"2021-07-05T08:00:43.696250Z","shell.execute_reply":"2021-07-05T08:00:43.867229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"initial_learningrate=2e-3\nbatch_size = 64\nepochs = 50\ninput_shape = (28, 28, 1)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:00:43.869431Z","iopub.execute_input":"2021-07-05T08:00:43.869769Z","iopub.status.idle":"2021-07-05T08:00:43.875416Z","shell.execute_reply.started":"2021-07-05T08:00:43.869734Z","shell.execute_reply":"2021-07-05T08:00:43.874463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(loss=\"categorical_crossentropy\",\n              optimizer=RMSprop(lr=initial_learningrate),\n              metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:00:43.877008Z","iopub.execute_input":"2021-07-05T08:00:43.877412Z","iopub.status.idle":"2021-07-05T08:00:43.890124Z","shell.execute_reply.started":"2021-07-05T08:00:43.877377Z","shell.execute_reply":"2021-07-05T08:00:43.889264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit_generator(\n      train_datagen.flow(X,Y, batch_size=batch_size),\n      steps_per_epoch=100,\n      epochs=epochs,\n      callbacks=[LearningRateScheduler(lr_decay)           \n               ],\n      validation_data=valid_datagen.flow(X_valid,Y_valid),\n      validation_steps=50,  \n      verbose=2)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:00:43.891443Z","iopub.execute_input":"2021-07-05T08:00:43.891811Z","iopub.status.idle":"2021-07-05T08:02:44.782885Z","shell.execute_reply.started":"2021-07-05T08:00:43.891773Z","shell.execute_reply":"2021-07-05T08:02:44.781976Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_dig=model.predict_classes(x_dig/255)\nmetrics.accuracy_score(preds_dig, y_dig)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:02:44.787141Z","iopub.execute_input":"2021-07-05T08:02:44.787421Z","iopub.status.idle":"2021-07-05T08:02:45.503331Z","shell.execute_reply.started":"2021-07-05T08:02:44.787391Z","shell.execute_reply":"2021-07-05T08:02:45.502416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = model.predict_classes(x_test/255.)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:02:45.504805Z","iopub.execute_input":"2021-07-05T08:02:45.505143Z","iopub.status.idle":"2021-07-05T08:02:45.958996Z","shell.execute_reply.started":"2021-07-05T08:02:45.505107Z","shell.execute_reply":"2021-07-05T08:02:45.958241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv('../input/Kannada-MNIST/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:02:45.960244Z","iopub.execute_input":"2021-07-05T08:02:45.960591Z","iopub.status.idle":"2021-07-05T08:02:45.972162Z","shell.execute_reply.started":"2021-07-05T08:02:45.960556Z","shell.execute_reply":"2021-07-05T08:02:45.971233Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['label'] = predictions","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:02:45.973409Z","iopub.execute_input":"2021-07-05T08:02:45.973742Z","iopub.status.idle":"2021-07-05T08:02:45.982421Z","shell.execute_reply.started":"2021-07-05T08:02:45.973705Z","shell.execute_reply":"2021-07-05T08:02:45.981573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:02:45.983629Z","iopub.execute_input":"2021-07-05T08:02:45.984036Z","iopub.status.idle":"2021-07-05T08:02:45.995268Z","shell.execute_reply.started":"2021-07-05T08:02:45.984000Z","shell.execute_reply":"2021-07-05T08:02:45.994193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv(\"submission.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T08:02:49.550810Z","iopub.execute_input":"2021-07-05T08:02:49.551131Z","iopub.status.idle":"2021-07-05T08:02:49.566498Z","shell.execute_reply.started":"2021-07-05T08:02:49.551100Z","shell.execute_reply":"2021-07-05T08:02:49.565711Z"},"trusted":true},"execution_count":null,"outputs":[]}]}