{"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":"markdown","source":"# Digit Recognizer","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport tensorflow as tf","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:06:56.456354Z","iopub.execute_input":"2023-03-18T15:06:56.456801Z","iopub.status.idle":"2023-03-18T15:07:08.067164Z","shell.execute_reply.started":"2023-03-18T15:06:56.456744Z","shell.execute_reply":"2023-03-18T15:07:08.065769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/digit-recognizer/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:08.069408Z","iopub.execute_input":"2023-03-18T15:07:08.070356Z","iopub.status.idle":"2023-03-18T15:07:11.908933Z","shell.execute_reply.started":"2023-03-18T15:07:08.070305Z","shell.execute_reply":"2023-03-18T15:07:11.907669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:11.910488Z","iopub.execute_input":"2023-03-18T15:07:11.910947Z","iopub.status.idle":"2023-03-18T15:07:11.953068Z","shell.execute_reply.started":"2023-03-18T15:07:11.910910Z","shell.execute_reply":"2023-03-18T15:07:11.951384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# so here first lets check if our data set contains any null values","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:11.955875Z","iopub.execute_input":"2023-03-18T15:07:11.956268Z","iopub.status.idle":"2023-03-18T15:07:11.962736Z","shell.execute_reply.started":"2023-03-18T15:07:11.956232Z","shell.execute_reply":"2023-03-18T15:07:11.961328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in range(len(df.isnull().sum())):\n    if df.isnull().sum()[i]!= 0:\n        print(df.isnull().sum())\nelse:\n    print(\"all good\")\n\n","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:11.965108Z","iopub.execute_input":"2023-03-18T15:07:11.965620Z","iopub.status.idle":"2023-03-18T15:07:47.127753Z","shell.execute_reply.started":"2023-03-18T15:07:11.965572Z","shell.execute_reply":"2023-03-18T15:07:47.126493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# lets now seperate dependent and independent variables","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.129211Z","iopub.execute_input":"2023-03-18T15:07:47.129964Z","iopub.status.idle":"2023-03-18T15:07:47.134998Z","shell.execute_reply.started":"2023-03-18T15:07:47.129925Z","shell.execute_reply":"2023-03-18T15:07:47.133668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"col = list(df.columns)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.137079Z","iopub.execute_input":"2023-03-18T15:07:47.137612Z","iopub.status.idle":"2023-03-18T15:07:47.149262Z","shell.execute_reply.started":"2023-03-18T15:07:47.137563Z","shell.execute_reply":"2023-03-18T15:07:47.147909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"col.remove(\"label\")","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.150801Z","iopub.execute_input":"2023-03-18T15:07:47.151177Z","iopub.status.idle":"2023-03-18T15:07:47.161152Z","shell.execute_reply.started":"2023-03-18T15:07:47.151143Z","shell.execute_reply":"2023-03-18T15:07:47.160080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df.drop(labels = [\"label\"],axis = 1 )","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.162949Z","iopub.execute_input":"2023-03-18T15:07:47.163347Z","iopub.status.idle":"2023-03-18T15:07:47.285294Z","shell.execute_reply.started":"2023-03-18T15:07:47.163305Z","shell.execute_reply":"2023-03-18T15:07:47.283841Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = df[\"label\"]","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.290827Z","iopub.execute_input":"2023-03-18T15:07:47.291218Z","iopub.status.idle":"2023-03-18T15:07:47.301407Z","shell.execute_reply.started":"2023-03-18T15:07:47.291184Z","shell.execute_reply":"2023-03-18T15:07:47.299968Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.303442Z","iopub.execute_input":"2023-03-18T15:07:47.304032Z","iopub.status.idle":"2023-03-18T15:07:47.328323Z","shell.execute_reply.started":"2023-03-18T15:07:47.303982Z","shell.execute_reply":"2023-03-18T15:07:47.327058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.330118Z","iopub.execute_input":"2023-03-18T15:07:47.330509Z","iopub.status.idle":"2023-03-18T15:07:47.341694Z","shell.execute_reply.started":"2023-03-18T15:07:47.330470Z","shell.execute_reply":"2023-03-18T15:07:47.340222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Now lets scale down our value ","metadata":{}},{"cell_type":"code","source":"x = x/255.0","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.343338Z","iopub.execute_input":"2023-03-18T15:07:47.343729Z","iopub.status.idle":"2023-03-18T15:07:47.421013Z","shell.execute_reply.started":"2023-03-18T15:07:47.343694Z","shell.execute_reply":"2023-03-18T15:07:47.419635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.422542Z","iopub.execute_input":"2023-03-18T15:07:47.423046Z","iopub.status.idle":"2023-03-18T15:07:47.459181Z","shell.execute_reply.started":"2023-03-18T15:07:47.422999Z","shell.execute_reply":"2023-03-18T15:07:47.457777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.461020Z","iopub.execute_input":"2023-03-18T15:07:47.461372Z","iopub.status.idle":"2023-03-18T15:07:47.469145Z","shell.execute_reply.started":"2023-03-18T15:07:47.461339Z","shell.execute_reply":"2023-03-18T15:07:47.468029Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Now lets reshape our x values","metadata":{}},{"cell_type":"code","source":"x = x.values.reshape(-1,28,28,1)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.470340Z","iopub.execute_input":"2023-03-18T15:07:47.471404Z","iopub.status.idle":"2023-03-18T15:07:47.478312Z","shell.execute_reply.started":"2023-03-18T15:07:47.471365Z","shell.execute_reply":"2023-03-18T15:07:47.476990Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x.shape","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.480347Z","iopub.execute_input":"2023-03-18T15:07:47.480948Z","iopub.status.idle":"2023-03-18T15:07:47.492542Z","shell.execute_reply.started":"2023-03-18T15:07:47.480892Z","shell.execute_reply":"2023-03-18T15:07:47.491141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Lets make a function to visualize our image","metadata":{}},{"cell_type":"code","source":"import random\ndef show():\n    plt.figure(figsize= (10,10))\n    for i in range(5):\n        r = random.randint(1,42000)\n        plt.subplot(1,5,i+1)\n        plt.subplots_adjust(hspace = .10,wspace = .10)\n        plt.imshow(x[r])\n        plt.title(y[r])","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:47.494433Z","iopub.execute_input":"2023-03-18T15:07:47.495506Z","iopub.status.idle":"2023-03-18T15:07:47.502555Z","shell.execute_reply.started":"2023-03-18T15:07:47.495457Z","shell.execute_reply":"2023-03-18T15:07:47.501327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2023-03-18T15:07:47.504225Z","iopub.execute_input":"2023-03-18T15:07:47.505156Z","iopub.status.idle":"2023-03-18T15:07:48.110774Z","shell.execute_reply.started":"2023-03-18T15:07:47.505114Z","shell.execute_reply":"2023-03-18T15:07:48.109470Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Now lets convert our y_label to categorical","metadata":{}},{"cell_type":"code","source":"y = tf.keras.utils.to_categorical(y)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:48.113040Z","iopub.execute_input":"2023-03-18T15:07:48.113552Z","iopub.status.idle":"2023-03-18T15:07:48.120511Z","shell.execute_reply.started":"2023-03-18T15:07:48.113501Z","shell.execute_reply":"2023-03-18T15:07:48.119111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Seqential Model Building","metadata":{}},{"cell_type":"code","source":"#del model\nmodel1 = tf.keras.models.Sequential()\n\n#Adding the first input layer and specifying the input shape\nmodel1.add(tf.keras.layers.Input((28,28),name = \"Input\"))\n\n#Add the flatten layers to the model\nmodel1.add(tf.keras.layers.Flatten(name = \"Flatten\"))\n\n#Hidden Layers\nmodel1.add(tf.keras.layers.Dense(100,activation = tf.keras.activations.relu, name = \"Hidden_Layer\"))\n\n#Output Layer\nmodel1.add(tf.keras.layers.Dense(10,activation = tf.keras.activations.softmax,name = \"Output_Layer\"))\n\n#now we are going to perform the back propagation to find out the error and to apply weights accordingly\nmodel1.compile(loss = tf.keras.losses.categorical_crossentropy,optimizer = tf.keras.optimizers.SGD(learning_rate = 0.01),\n             metrics = \"acc\")\n\n#And now finnaly we are going to apply our data to our model\nmodel1.fit(x =x,y =y, epochs = 10, validation_split = 0.1)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:07:48.122118Z","iopub.execute_input":"2023-03-18T15:07:48.122475Z","iopub.status.idle":"2023-03-18T15:08:23.980087Z","shell.execute_reply.started":"2023-03-18T15:07:48.122442Z","shell.execute_reply":"2023-03-18T15:08:23.978860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Trying with different hyperparameters to increase our model accuracy","metadata":{}},{"cell_type":"code","source":"#del model2\nmodel2 = tf.keras.models.Sequential()\n\n#Adding the first input layer and specifying the input shape\nmodel2.add(tf.keras.layers.Input((28,28),name = \"Input\"))\n\n#Add the flatten layers to the model\nmodel2.add(tf.keras.layers.Flatten(name = \"Flatten\"))\n\n#Hidden Layers\nmodel2.add(tf.keras.layers.Dense(100,activation = tf.keras.activations.relu, name = \"Hidden_Layer1\"))\nmodel2.add(tf.keras.layers.Dense(200,activation = tf.keras.activations.relu, name = \"Hidden_Layer2\"))\nmodel2.add(tf.keras.layers.Dense(300,activation = tf.keras.activations.relu, name = \"Hidden_Layer3\"))\n\n#Output Layer\nmodel2.add(tf.keras.layers.Dense(10,activation = tf.keras.activations.softmax,name = \"Output_Layer\"))\n\n#now we are going to perform the back propagation to find out the error and to apply weights accordingly\nmodel2.compile(loss = tf.keras.losses.categorical_crossentropy,optimizer = tf.keras.optimizers.Adam(learning_rate = 0.01),\n             metrics = \"acc\")\n\n#And now finnaly we are going to apply our data to our model\nmodel2.fit(x =x,y =y, epochs = 20, validation_split = 0.1)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:13:27.295044Z","iopub.execute_input":"2023-03-18T15:13:27.295541Z","iopub.status.idle":"2023-03-18T15:15:20.340897Z","shell.execute_reply.started":"2023-03-18T15:13:27.295447Z","shell.execute_reply":"2023-03-18T15:15:20.339363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#del model\nmodel3 = tf.keras.models.Sequential()\n\n#Adding the first input layer and specifying the input shape\nmodel3.add(tf.keras.layers.Input((28,28),name = \"Input\"))\n\n#Add the flatten layers to the model\nmodel3.add(tf.keras.layers.Flatten(name = \"Flatten\"))\n\n#Hidden Layers\nmodel3.add(tf.keras.layers.Dense(100,activation = tf.keras.activations.relu, name = \"Hidden_Layer1\"))\nmodel3.add(tf.keras.layers.Dense(200,activation = tf.keras.activations.relu, name = \"Hidden_Layer2\"))\nmodel3.add(tf.keras.layers.Dense(300,activation = tf.keras.activations.relu, name = \"Hidden_Layer3\"))\n\n#Output Layer\nmodel3.add(tf.keras.layers.Dense(10,activation = tf.keras.activations.softmax,name = \"Output_Layer\"))\n\n#now we are going to perform the back propagation to find out the error and to apply weights accordingly\nmodel3.compile(loss = tf.keras.losses.categorical_crossentropy,optimizer = tf.keras.optimizers.Adam(learning_rate = 0.1),\n             metrics = \"acc\")\n\n#And now finnaly we are going to apply our data to our model\nmodel3.fit(x =x,y =y, epochs = 20, validation_split = 0.1)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:18:03.150940Z","iopub.execute_input":"2023-03-18T15:18:03.151370Z","iopub.status.idle":"2023-03-18T15:19:54.490994Z","shell.execute_reply.started":"2023-03-18T15:18:03.151333Z","shell.execute_reply":"2023-03-18T15:19:54.489504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#del model4\nmodel4 = tf.keras.models.Sequential()\n\n#Adding the first input layer and specifying the input shape\nmodel4.add(tf.keras.layers.Input((28,28),name = \"Input\"))\n\n#Add the flatten layers to the model\nmodel4.add(tf.keras.layers.Flatten(name = \"Flatten\"))\n\n#Hidden Layers\nmodel4.add(tf.keras.layers.Dense(100,activation = tf.keras.activations.relu, name = \"Hidden_Layer1\"))\nmodel4.add(tf.keras.layers.Dense(200,activation = tf.keras.activations.relu, name = \"Hidden_Layer2\"))\nmodel4.add(tf.keras.layers.Dense(300,activation = tf.keras.activations.relu, name = \"Hidden_Layer3\"))\n\n#Output Layer\nmodel4.add(tf.keras.layers.Dense(10,activation = tf.keras.activations.softmax,name = \"Output_Layer\"))\n\n#now we are going to perform the back propagation to find out the error and to apply weights accordingly\nmodel4.compile(loss = tf.keras.losses.categorical_crossentropy,optimizer = tf.keras.optimizers.Adam(learning_rate = 0.01),\n             metrics = \"acc\")\n\n#And now finnaly we are going to apply our data to our model\nmodel_history = model4.fit(x =x,y =y, epochs = 30, validation_split = 0.1)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:21:15.632246Z","iopub.execute_input":"2023-03-18T15:21:15.632974Z","iopub.status.idle":"2023-03-18T15:24:38.870268Z","shell.execute_reply.started":"2023-03-18T15:21:15.632918Z","shell.execute_reply":"2023-03-18T15:24:38.868843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Visualizing our models performance","metadata":{}},{"cell_type":"code","source":"model_history.history.keys()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:38.873748Z","iopub.execute_input":"2023-03-18T15:24:38.874182Z","iopub.status.idle":"2023-03-18T15:24:38.882076Z","shell.execute_reply.started":"2023-03-18T15:24:38.874141Z","shell.execute_reply":"2023-03-18T15:24:38.880472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_history.history[\"loss\"]","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:38.883751Z","iopub.execute_input":"2023-03-18T15:24:38.884227Z","iopub.status.idle":"2023-03-18T15:24:38.896428Z","shell.execute_reply.started":"2023-03-18T15:24:38.884178Z","shell.execute_reply":"2023-03-18T15:24:38.895129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(model_history.history[\"loss\"],label = \"Training_Loss\")\nplt.plot(model_history.history[\"val_loss\"],label = \"Validation_Loss\")\nplt.legend()\nplt.title(\"Training vs Validation Loss\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:38.899194Z","iopub.execute_input":"2023-03-18T15:24:38.899596Z","iopub.status.idle":"2023-03-18T15:24:39.157233Z","shell.execute_reply.started":"2023-03-18T15:24:38.899539Z","shell.execute_reply":"2023-03-18T15:24:39.155863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(model_history.history[\"acc\"],label = \"Training_Accuracy\")\nplt.plot(model_history.history[\"val_acc\"],label = \"Validation_Accuracy\")\nplt.legend()\nplt.title(\"Training vs Validation Accuracy\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:39.160039Z","iopub.execute_input":"2023-03-18T15:24:39.160992Z","iopub.status.idle":"2023-03-18T15:24:39.401720Z","shell.execute_reply.started":"2023-03-18T15:24:39.160936Z","shell.execute_reply":"2023-03-18T15:24:39.400458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv(\"/kaggle/input/digit-recognizer/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:39.403227Z","iopub.execute_input":"2023-03-18T15:24:39.403744Z","iopub.status.idle":"2023-03-18T15:24:41.497612Z","shell.execute_reply.started":"2023-03-18T15:24:39.403707Z","shell.execute_reply":"2023-03-18T15:24:41.496133Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:41.499274Z","iopub.execute_input":"2023-03-18T15:24:41.499839Z","iopub.status.idle":"2023-03-18T15:24:41.521869Z","shell.execute_reply.started":"2023-03-18T15:24:41.499792Z","shell.execute_reply":"2023-03-18T15:24:41.520453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test/255.0","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:41.523425Z","iopub.execute_input":"2023-03-18T15:24:41.523926Z","iopub.status.idle":"2023-03-18T15:24:41.579672Z","shell.execute_reply.started":"2023-03-18T15:24:41.523885Z","shell.execute_reply":"2023-03-18T15:24:41.578621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test.values.reshape(-1,28,28,1)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:41.580643Z","iopub.execute_input":"2023-03-18T15:24:41.581015Z","iopub.status.idle":"2023-03-18T15:24:41.587795Z","shell.execute_reply.started":"2023-03-18T15:24:41.580972Z","shell.execute_reply":"2023-03-18T15:24:41.586833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# so here we are taking model4 because im having a better result form model4 than model3","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:41.592122Z","iopub.execute_input":"2023-03-18T15:24:41.593097Z","iopub.status.idle":"2023-03-18T15:24:41.598716Z","shell.execute_reply.started":"2023-03-18T15:24:41.593047Z","shell.execute_reply":"2023-03-18T15:24:41.597553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model4.predict(test)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:41.600650Z","iopub.execute_input":"2023-03-18T15:24:41.601086Z","iopub.status.idle":"2023-03-18T15:24:44.309129Z","shell.execute_reply.started":"2023-03-18T15:24:41.601049Z","shell.execute_reply":"2023-03-18T15:24:44.308050Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:44.311176Z","iopub.execute_input":"2023-03-18T15:24:44.311860Z","iopub.status.idle":"2023-03-18T15:24:44.319093Z","shell.execute_reply.started":"2023-03-18T15:24:44.311817Z","shell.execute_reply":"2023-03-18T15:24:44.318024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Concat Label and ImageId columns","metadata":{}},{"cell_type":"code","source":"\n\n\nImageId = np.arange(1, 28001)\nLabel = np.argmax(prediction, axis = 1)\nLabel = Label.reshape(-1, 1)\nImageId = ImageId.reshape(-1, 1)\n\nsubmission = np.concatenate((ImageId, Label), axis = 1)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:44.320468Z","iopub.execute_input":"2023-03-18T15:24:44.321318Z","iopub.status.idle":"2023-03-18T15:24:44.331833Z","shell.execute_reply.started":"2023-03-18T15:24:44.321257Z","shell.execute_reply":"2023-03-18T15:24:44.330858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:44.333385Z","iopub.execute_input":"2023-03-18T15:24:44.334749Z","iopub.status.idle":"2023-03-18T15:24:44.351687Z","shell.execute_reply.started":"2023-03-18T15:24:44.334698Z","shell.execute_reply":"2023-03-18T15:24:44.350290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame(submission).apply(np.int64)\nsubmission = submission.rename(columns = {0: \"ImageId\", 1: \"Label\"})","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:44.353714Z","iopub.execute_input":"2023-03-18T15:24:44.354242Z","iopub.status.idle":"2023-03-18T15:24:44.363701Z","shell.execute_reply.started":"2023-03-18T15:24:44.354189Z","shell.execute_reply":"2023-03-18T15:24:44.362499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:44.365362Z","iopub.execute_input":"2023-03-18T15:24:44.366016Z","iopub.status.idle":"2023-03-18T15:24:44.381346Z","shell.execute_reply.started":"2023-03-18T15:24:44.365970Z","shell.execute_reply":"2023-03-18T15:24:44.380232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Converting our prediction to  csv file","metadata":{}},{"cell_type":"code","source":"submission.to_csv(\"submission.csv\",index = None)","metadata":{"execution":{"iopub.status.busy":"2023-03-18T15:24:44.383098Z","iopub.execute_input":"2023-03-18T15:24:44.383870Z","iopub.status.idle":"2023-03-18T15:24:44.427394Z","shell.execute_reply.started":"2023-03-18T15:24:44.383818Z","shell.execute_reply":"2023-03-18T15:24:44.426182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}