{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":3004,"databundleVersionId":861823,"sourceType":"competition"}],"dockerImageVersionId":30664,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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":"2024-03-03T13:04:09.842447Z","iopub.execute_input":"2024-03-03T13:04:09.842862Z","iopub.status.idle":"2024-03-03T13:04:11.383459Z","shell.execute_reply.started":"2024-03-03T13:04:09.842828Z","shell.execute_reply":"2024-03-03T13:04:11.382198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense,Conv2D,MaxPool2D,Flatten\nfrom tensorflow.keras.callbacks import EarlyStopping\nfrom tensorflow.keras.datasets import mnist\nfrom tensorflow.keras.utils import to_categorical\nfrom sklearn.metrics import confusion_matrix,accuracy_score\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:11.385516Z","iopub.execute_input":"2024-03-03T13:04:11.386767Z","iopub.status.idle":"2024-03-03T13:04:28.622688Z","shell.execute_reply.started":"2024-03-03T13:04:11.386720Z","shell.execute_reply":"2024-03-03T13:04:28.620551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Loading MNIST data","metadata":{}},{"cell_type":"code","source":"(X_train,y_train),(X_test,y_test) = mnist.load_data()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:28.624563Z","iopub.execute_input":"2024-03-03T13:04:28.625263Z","iopub.status.idle":"2024-03-03T13:04:30.376696Z","shell.execute_reply.started":"2024-03-03T13:04:28.625227Z","shell.execute_reply":"2024-03-03T13:04:30.375429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.380608Z","iopub.execute_input":"2024-03-03T13:04:30.381104Z","iopub.status.idle":"2024-03-03T13:04:30.389717Z","shell.execute_reply.started":"2024-03-03T13:04:30.381045Z","shell.execute_reply":"2024-03-03T13:04:30.388500Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.391504Z","iopub.execute_input":"2024-03-03T13:04:30.392042Z","iopub.status.idle":"2024-03-03T13:04:30.401395Z","shell.execute_reply.started":"2024-03-03T13:04:30.391998Z","shell.execute_reply":"2024-03-03T13:04:30.400033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.403077Z","iopub.execute_input":"2024-03-03T13:04:30.403582Z","iopub.status.idle":"2024-03-03T13:04:30.412217Z","shell.execute_reply.started":"2024-03-03T13:04:30.403542Z","shell.execute_reply":"2024-03-03T13:04:30.410810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Visualizing single array image","metadata":{}},{"cell_type":"code","source":"single_image = X_train[0]","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.413635Z","iopub.execute_input":"2024-03-03T13:04:30.413978Z","iopub.status.idle":"2024-03-03T13:04:30.424920Z","shell.execute_reply.started":"2024-03-03T13:04:30.413949Z","shell.execute_reply":"2024-03-03T13:04:30.423450Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"single_image","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.427124Z","iopub.execute_input":"2024-03-03T13:04:30.427615Z","iopub.status.idle":"2024-03-03T13:04:30.445121Z","shell.execute_reply.started":"2024-03-03T13:04:30.427579Z","shell.execute_reply":"2024-03-03T13:04:30.443592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Since it is a 2D array(28,28) matplotlib will easily do\nplt.imshow(single_image) ## Gray Scale image (Color is because default cmap of matplotlib)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.446900Z","iopub.execute_input":"2024-03-03T13:04:30.447472Z","iopub.status.idle":"2024-03-03T13:04:30.785735Z","shell.execute_reply.started":"2024-03-03T13:04:30.447418Z","shell.execute_reply":"2024-03-03T13:04:30.784403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Preprocessing the Data","metadata":{}},{"cell_type":"code","source":"# reshaping the img array in the way to mention the (batch_size,width,height,color_channels)\nX_train = X_train.reshape(60000,28,28,1)\nX_test = X_test.reshape(10000,28,28,1)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.792349Z","iopub.execute_input":"2024-03-03T13:04:30.792745Z","iopub.status.idle":"2024-03-03T13:04:30.800024Z","shell.execute_reply.started":"2024-03-03T13:04:30.792715Z","shell.execute_reply":"2024-03-03T13:04:30.798123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#one hot encoding by keras.utils \ny_train_c = to_categorical(y_train)\ny_test_c = to_categorical(y_test)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.801557Z","iopub.execute_input":"2024-03-03T13:04:30.801941Z","iopub.status.idle":"2024-03-03T13:04:30.818198Z","shell.execute_reply.started":"2024-03-03T13:04:30.801911Z","shell.execute_reply":"2024-03-03T13:04:30.816621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train_c.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.819813Z","iopub.execute_input":"2024-03-03T13:04:30.820230Z","iopub.status.idle":"2024-03-03T13:04:30.827886Z","shell.execute_reply.started":"2024-03-03T13:04:30.820198Z","shell.execute_reply":"2024-03-03T13:04:30.826606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train_c[9] ## the index is 4 means the it is digit 4","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.829625Z","iopub.execute_input":"2024-03-03T13:04:30.830382Z","iopub.status.idle":"2024-03-03T13:04:30.839476Z","shell.execute_reply.started":"2024-03-03T13:04:30.830345Z","shell.execute_reply":"2024-03-03T13:04:30.838203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#normalizing the X data\nX_train.max() , X_train.min()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.841071Z","iopub.execute_input":"2024-03-03T13:04:30.841905Z","iopub.status.idle":"2024-03-03T13:04:30.861652Z","shell.execute_reply.started":"2024-03-03T13:04:30.841840Z","shell.execute_reply":"2024-03-03T13:04:30.860540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#since the pixels are from 1 to 255 \n#we can easily standardize into(0,1) by dividing them all by 255\n\nX_train = X_train/255\nX_test = X_test/255","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:30.863197Z","iopub.execute_input":"2024-03-03T13:04:30.863972Z","iopub.status.idle":"2024-03-03T13:04:31.078499Z","shell.execute_reply.started":"2024-03-03T13:04:30.863927Z","shell.execute_reply":"2024-03-03T13:04:31.077291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train[4].shape ,X_train[4].max() #done ","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:31.080073Z","iopub.execute_input":"2024-03-03T13:04:31.080551Z","iopub.status.idle":"2024-03-03T13:04:31.088402Z","shell.execute_reply.started":"2024-03-03T13:04:31.080511Z","shell.execute_reply":"2024-03-03T13:04:31.087322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Building CNN Model","metadata":{}},{"cell_type":"code","source":"model = Sequential()\n#adding the layers in the order -> (CNN,POOL,FC,OUT)\n\nmodel.add(Conv2D(filters=32,kernel_size=(4,4),input_shape=(28,28,1),padding='Same',activation='relu')) #inputshape of one img array\n\n\nmodel.add(Conv2D(filters=16,kernel_size=(4,4),padding='Same',activation='relu')) #inputshape of one img array\nmodel.add(MaxPool2D(pool_size=(4,4)))\n\nmodel.add(Conv2D(filters=16,kernel_size=(4,4),padding='Same',activation='relu')) #inputshape of one img array\nmodel.add(MaxPool2D(pool_size=(4,4)))\n#before going to the FC the output feature should be flatten out\nmodel.add(Flatten())\nmodel.add(Dense(128,activation='relu'))\nmodel.add(Dense(64,activation='relu'))\n#Output layer-> 10 neurons since it has 10 classes\nmodel.add(Dense(10,activation='softmax'))","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:31.089835Z","iopub.execute_input":"2024-03-03T13:04:31.090199Z","iopub.status.idle":"2024-03-03T13:04:31.264731Z","shell.execute_reply.started":"2024-03-03T13:04:31.090169Z","shell.execute_reply":"2024-03-03T13:04:31.263412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:31.266308Z","iopub.execute_input":"2024-03-03T13:04:31.266774Z","iopub.status.idle":"2024-03-03T13:04:31.285755Z","shell.execute_reply.started":"2024-03-03T13:04:31.266732Z","shell.execute_reply":"2024-03-03T13:04:31.284449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Earlystoppings to prevent the model from overfittings\ncallback = EarlyStopping(min_delta=0.001,patience=1,restore_best_weights=True)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:31.287233Z","iopub.execute_input":"2024-03-03T13:04:31.288016Z","iopub.status.idle":"2024-03-03T13:04:31.293634Z","shell.execute_reply.started":"2024-03-03T13:04:31.287970Z","shell.execute_reply":"2024-03-03T13:04:31.292040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(x=X_train,y=y_train_c,validation_data=(X_test,y_test_c),batch_size=256,epochs=60,callbacks=[callback])","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:04:31.295683Z","iopub.execute_input":"2024-03-03T13:04:31.296179Z","iopub.status.idle":"2024-03-03T13:14:46.368478Z","shell.execute_reply.started":"2024-03-03T13:04:31.296137Z","shell.execute_reply":"2024-03-03T13:14:46.367008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Model Evaluation","metadata":{}},{"cell_type":"code","source":"history = pd.DataFrame(model.history.history)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:46.370179Z","iopub.execute_input":"2024-03-03T13:14:46.370704Z","iopub.status.idle":"2024-03-03T13:14:46.381767Z","shell.execute_reply.started":"2024-03-03T13:14:46.370658Z","shell.execute_reply":"2024-03-03T13:14:46.380698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history[['loss','val_loss']].plot() #Callbacks helps to prevent model from overfitting\n#can see that epoch stopped when there is slight increase in val_loss and decrease in loss","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:46.383134Z","iopub.execute_input":"2024-03-03T13:14:46.383596Z","iopub.status.idle":"2024-03-03T13:14:46.765662Z","shell.execute_reply.started":"2024-03-03T13:14:46.383562Z","shell.execute_reply":"2024-03-03T13:14:46.764630Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### So Perfect Graph Above","metadata":{}},{"cell_type":"code","source":"model.evaluate(X_test,y_test_c)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:46.767164Z","iopub.execute_input":"2024-03-03T13:14:46.767782Z","iopub.status.idle":"2024-03-03T13:14:50.533790Z","shell.execute_reply.started":"2024-03-03T13:14:46.767751Z","shell.execute_reply":"2024-03-03T13:14:50.532522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = np.argmax(model.predict(X_test.reshape(10000,28,28,1)),axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:50.535263Z","iopub.execute_input":"2024-03-03T13:14:50.536199Z","iopub.status.idle":"2024-03-03T13:14:54.559298Z","shell.execute_reply.started":"2024-03-03T13:14:50.536162Z","shell.execute_reply":"2024-03-03T13:14:54.558246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(confusion_matrix(y_test,y_pred))","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:54.560647Z","iopub.execute_input":"2024-03-03T13:14:54.561430Z","iopub.status.idle":"2024-03-03T13:14:55.008603Z","shell.execute_reply.started":"2024-03-03T13:14:54.561395Z","shell.execute_reply":"2024-03-03T13:14:55.007191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.010266Z","iopub.execute_input":"2024-03-03T13:14:55.010769Z","iopub.status.idle":"2024-03-03T13:14:55.021374Z","shell.execute_reply.started":"2024-03-03T13:14:55.010736Z","shell.execute_reply":"2024-03-03T13:14:55.019256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Accuracy_Score:------------')\naccuracy_score(y_test,y_pred)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.023337Z","iopub.execute_input":"2024-03-03T13:14:55.023755Z","iopub.status.idle":"2024-03-03T13:14:55.036354Z","shell.execute_reply.started":"2024-03-03T13:14:55.023724Z","shell.execute_reply":"2024-03-03T13:14:55.034909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Prediction","metadata":{}},{"cell_type":"code","source":"sample_image = X_test[99]","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.043633Z","iopub.execute_input":"2024-03-03T13:14:55.044028Z","iopub.status.idle":"2024-03-03T13:14:55.049050Z","shell.execute_reply.started":"2024-03-03T13:14:55.043997Z","shell.execute_reply":"2024-03-03T13:14:55.047713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_image = sample_image","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.050592Z","iopub.execute_input":"2024-03-03T13:14:55.051015Z","iopub.status.idle":"2024-03-03T13:14:55.060877Z","shell.execute_reply.started":"2024-03-03T13:14:55.050982Z","shell.execute_reply":"2024-03-03T13:14:55.059444Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(sample_image)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.063420Z","iopub.execute_input":"2024-03-03T13:14:55.063924Z","iopub.status.idle":"2024-03-03T13:14:55.363982Z","shell.execute_reply.started":"2024-03-03T13:14:55.063880Z","shell.execute_reply":"2024-03-03T13:14:55.362787Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred = model.predict(sample_image.reshape(1,28,28,1)) #(batch,height,width,color)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.365396Z","iopub.execute_input":"2024-03-03T13:14:55.366140Z","iopub.status.idle":"2024-03-03T13:14:55.458034Z","shell.execute_reply.started":"2024-03-03T13:14:55.366069Z","shell.execute_reply":"2024-03-03T13:14:55.456509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classes = np.argmax(pred,axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.460356Z","iopub.execute_input":"2024-03-03T13:14:55.460761Z","iopub.status.idle":"2024-03-03T13:14:55.466390Z","shell.execute_reply.started":"2024-03-03T13:14:55.460728Z","shell.execute_reply":"2024-03-03T13:14:55.465385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classes #thus it is-> 9","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.467768Z","iopub.execute_input":"2024-03-03T13:14:55.468385Z","iopub.status.idle":"2024-03-03T13:14:55.487021Z","shell.execute_reply.started":"2024-03-03T13:14:55.468349Z","shell.execute_reply":"2024-03-03T13:14:55.485755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submission","metadata":{}},{"cell_type":"code","source":"test = pd.read_csv(r\"/kaggle/input/digit-recognizer/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:55.489076Z","iopub.execute_input":"2024-03-03T13:14:55.490579Z","iopub.status.idle":"2024-03-03T13:14:57.874458Z","shell.execute_reply.started":"2024-03-03T13:14:55.490518Z","shell.execute_reply":"2024-03-03T13:14:57.873115Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head(1)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:57.876539Z","iopub.execute_input":"2024-03-03T13:14:57.877045Z","iopub.status.idle":"2024-03-03T13:14:57.904170Z","shell.execute_reply.started":"2024-03-03T13:14:57.877002Z","shell.execute_reply":"2024-03-03T13:14:57.902635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_array = test.values","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:57.905897Z","iopub.execute_input":"2024-03-03T13:14:57.906330Z","iopub.status.idle":"2024-03-03T13:14:57.913257Z","shell.execute_reply.started":"2024-03-03T13:14:57.906285Z","shell.execute_reply":"2024-03-03T13:14:57.911862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:57.914995Z","iopub.execute_input":"2024-03-03T13:14:57.915469Z","iopub.status.idle":"2024-03-03T13:14:57.926012Z","shell.execute_reply.started":"2024-03-03T13:14:57.915421Z","shell.execute_reply":"2024-03-03T13:14:57.924793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(test_array[111].reshape(28,28))","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:57.927571Z","iopub.execute_input":"2024-03-03T13:14:57.928259Z","iopub.status.idle":"2024-03-03T13:14:58.228578Z","shell.execute_reply.started":"2024-03-03T13:14:57.928215Z","shell.execute_reply":"2024-03-03T13:14:58.227342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_arr = test_array.reshape(28000,28,28,1)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:58.230160Z","iopub.execute_input":"2024-03-03T13:14:58.230595Z","iopub.status.idle":"2024-03-03T13:14:58.236983Z","shell.execute_reply.started":"2024-03-03T13:14:58.230556Z","shell.execute_reply":"2024-03-03T13:14:58.235300Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_arr.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:58.238523Z","iopub.execute_input":"2024-03-03T13:14:58.238979Z","iopub.status.idle":"2024-03-03T13:14:58.252605Z","shell.execute_reply.started":"2024-03-03T13:14:58.238949Z","shell.execute_reply":"2024-03-03T13:14:58.251184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_pred = np.argmax(model.predict(test_arr),axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:14:58.254001Z","iopub.execute_input":"2024-03-03T13:14:58.254405Z","iopub.status.idle":"2024-03-03T13:15:09.851588Z","shell.execute_reply.started":"2024-03-03T13:14:58.254375Z","shell.execute_reply":"2024-03-03T13:15:09.850371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv(r\"/kaggle/input/digit-recognizer/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:15:09.853345Z","iopub.execute_input":"2024-03-03T13:15:09.853848Z","iopub.status.idle":"2024-03-03T13:15:09.874777Z","shell.execute_reply.started":"2024-03-03T13:15:09.853747Z","shell.execute_reply":"2024-03-03T13:15:09.873566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.head(0)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:15:09.876726Z","iopub.execute_input":"2024-03-03T13:15:09.877466Z","iopub.status.idle":"2024-03-03T13:15:09.889440Z","shell.execute_reply.started":"2024-03-03T13:15:09.877429Z","shell.execute_reply":"2024-03-03T13:15:09.887882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['Label']=sub_pred","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:15:09.891116Z","iopub.execute_input":"2024-03-03T13:15:09.891732Z","iopub.status.idle":"2024-03-03T13:15:09.898396Z","shell.execute_reply.started":"2024-03-03T13:15:09.891691Z","shell.execute_reply":"2024-03-03T13:15:09.897067Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('Submission.csv',index=False)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T13:15:09.900175Z","iopub.execute_input":"2024-03-03T13:15:09.900744Z","iopub.status.idle":"2024-03-03T13:15:09.951212Z","shell.execute_reply.started":"2024-03-03T13:15:09.900709Z","shell.execute_reply":"2024-03-03T13:15:09.949480Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}