{"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":"2022-08-04T09:31:02.267814Z","iopub.execute_input":"2022-08-04T09:31:02.268248Z","iopub.status.idle":"2022-08-04T09:31:02.279007Z","shell.execute_reply.started":"2022-08-04T09:31:02.268215Z","shell.execute_reply":"2022-08-04T09:31:02.277491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data=pd.read_csv(r\"/kaggle/input/digit-recognizer/train.csv\")\ndata.loc\n#data.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:31:06.465456Z","iopub.execute_input":"2022-08-04T09:31:06.466008Z","iopub.status.idle":"2022-08-04T09:31:11.978050Z","shell.execute_reply.started":"2022-08-04T09:31:06.465962Z","shell.execute_reply":"2022-08-04T09:31:11.976606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def dataset_generator(filepath):\n    file = pd.read_csv(filepath)\n    image_dataset = []\n    \n    if 'train' in filepath:\n        label_dataset = file.loc[:,'label'].values.tolist()\n    else:\n        label_dataset = []\n    \n    # Iterating through each lines of the file\n    \n    for i in range(len(file)):\n        #As the train dataset conatins the label parameter so we are starting from 2nd column\n        start = 1\n        if  'test' in filepath:\n            start=0 # As the test dataset doesnot contain the label parameter\n        current_line = file.loc[i] #The .loc function is used to filter out \n        image = np.array(current_line[start:len(file.loc[i])])\n        image = image.reshape(28,28)\n        image = image / 225\n        image_dataset.append(image)\n    \n    # Now convert tha image dataset and the label dataset into arrays\n    \n    image_dataset = np.array(image_dataset)\n    label_dataset = np.array(label_dataset)\n    \n    #Expanding the dimensions\n    \n    image_dataset = np.expand_dims(image_dataset, -1)\n    label_dataset = np.expand_dims(label_dataset,-1)\n    \n    print(\"The shape of the image and amount\", type(image_dataset), image_dataset.shape)\n    print(\"The shape of the label and amount\", type(label_dataset), label_dataset.shape)\n    return image_dataset,label_dataset\n    \n\ntrain_images, train_labels = dataset_generator(r\"/kaggle/input/digit-recognizer/train.csv\")\n    \n","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:31:17.625364Z","iopub.execute_input":"2022-08-04T09:31:17.626028Z","iopub.status.idle":"2022-08-04T09:31:41.893329Z","shell.execute_reply.started":"2022-08-04T09:31:17.625972Z","shell.execute_reply":"2022-08-04T09:31:41.890995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def dataset_generator(filepath):\n    file = pd.read_csv(filepath)\n    image_dataset = []\n    \n    if 'train' in filepath:\n        label_dataset = file.loc[:,'label'].values.tolist()\n    else:\n        label_dataset = []\n    \n    # Iterating through each lines of the file\n    \n    for i in range(len(file)):\n        #As the train dataset conatins the label parameter so we are starting from 2nd column\n        start = 1\n        if  'test' in filepath:\n            start=0 # As the test dataset doesnot contain the label parameter\n        current_line = file.loc[i] #The .loc function is used to filter out \n        image = np.array(current_line[start:len(file.loc[i])])\n        image = image.reshape(28,28)\n        image = image / 225\n        image_dataset.append(image)\n    \n    # Now convert tha image dataset and the label dataset into arrays\n    \n    image_dataset = np.array(image_dataset)\n    label_dataset = np.array(label_dataset)\n    \n    #Expanding the dimensions\n    \n    image_dataset = np.expand_dims(image_dataset, -1)\n    label_dataset = np.expand_dims(label_dataset,-1)\n    \n    print(\"The shape of the image and amount\", type(image_dataset), image_dataset.shape)\n    print(\"The shape of the label and amount\", type(label_dataset), label_dataset.shape)\n    return image_dataset,label_dataset\n    \n\ntest_images, test_labels = dataset_generator(r\"/kaggle/input/digit-recognizer/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:31:49.063175Z","iopub.execute_input":"2022-08-04T09:31:49.063646Z","iopub.status.idle":"2022-08-04T09:32:02.612994Z","shell.execute_reply.started":"2022-08-04T09:31:49.063613Z","shell.execute_reply":"2022-08-04T09:32:02.611415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_labels[:10])","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:32:09.747125Z","iopub.execute_input":"2022-08-04T09:32:09.747531Z","iopub.status.idle":"2022-08-04T09:32:09.755566Z","shell.execute_reply.started":"2022-08-04T09:32:09.747498Z","shell.execute_reply":"2022-08-04T09:32:09.754035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# One Hot Encoding\nfrom keras.utils.np_utils import to_categorical\n\ntrain_labels = to_categorical(train_labels)\n\nprint(f\"Label size {train_labels.shape}\")","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:32:13.743083Z","iopub.execute_input":"2022-08-04T09:32:13.743857Z","iopub.status.idle":"2022-08-04T09:32:20.157898Z","shell.execute_reply.started":"2022-08-04T09:32:13.743798Z","shell.execute_reply":"2022-08-04T09:32:20.156376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Viewing an image \nimport matplotlib.pyplot as plt\nplt.imshow(train_images[3], cmap='Greys_r')","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:32:34.563167Z","iopub.execute_input":"2022-08-04T09:32:34.563891Z","iopub.status.idle":"2022-08-04T09:32:34.824246Z","shell.execute_reply.started":"2022-08-04T09:32:34.563855Z","shell.execute_reply":"2022-08-04T09:32:34.822904Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Viewing an image \nimport matplotlib.pyplot as plt\nplt.imshow(test_images[3], cmap='Greys_r')","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:32:59.120751Z","iopub.execute_input":"2022-08-04T09:32:59.121186Z","iopub.status.idle":"2022-08-04T09:32:59.346629Z","shell.execute_reply.started":"2022-08-04T09:32:59.121156Z","shell.execute_reply":"2022-08-04T09:32:59.345101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Dividing the train dataset","metadata":{}},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\nx_train, x_test, y_train, y_test = train_test_split(train_images, train_labels, test_size=0.1, random_state=0)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:33:34.843280Z","iopub.execute_input":"2022-08-04T09:33:34.843732Z","iopub.status.idle":"2022-08-04T09:33:34.959539Z","shell.execute_reply.started":"2022-08-04T09:33:34.843699Z","shell.execute_reply":"2022-08-04T09:33:34.958195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train.shape, x_test.shape, y_train.shape, y_test.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:33:49.076999Z","iopub.execute_input":"2022-08-04T09:33:49.077421Z","iopub.status.idle":"2022-08-04T09:33:49.087379Z","shell.execute_reply.started":"2022-08-04T09:33:49.077388Z","shell.execute_reply":"2022-08-04T09:33:49.085696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Augmentation ","metadata":{}},{"cell_type":"code","source":"import cv2\nfrom skimage import io\nfrom skimage.transform import rotate, AffineTransform, warp\nimport random\nfrom skimage.util import random_noise\n","metadata":{"execution":{"iopub.status.busy":"2022-08-04T06:56:30.456648Z","iopub.execute_input":"2022-08-04T06:56:30.457013Z","iopub.status.idle":"2022-08-04T06:56:31.244153Z","shell.execute_reply.started":"2022-08-04T06:56:30.456982Z","shell.execute_reply":"2022-08-04T06:56:31.243155Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### The functions fro Data Augmentation","metadata":{}},{"cell_type":"code","source":"'''#The functions for performing the data augmentation\ndef anticlockwise_rotation(image):\n    angle = random.randint(0,180)\n    return rotate(image, angle)\n\ndef horizontal_flip(image):\n    return np.fliplr(image)\n\ndef vertical_flip(image):\n    return np.flipud(image)\n\ndef clockwise_rotation(image):\n    angle = random.randint(0,180)\n    return rotate(image,angle)\n\ndef add_noise(image):\n    return random_noise(image)\n\ndef blur_image(image):\n    return cv2.GaussianBlur(image, (9,9), 0)\n'''","metadata":{"execution":{"iopub.status.busy":"2022-08-04T06:56:33.680738Z","iopub.execute_input":"2022-08-04T06:56:33.681139Z","iopub.status.idle":"2022-08-04T06:56:33.688743Z","shell.execute_reply.started":"2022-08-04T06:56:33.681083Z","shell.execute_reply":"2022-08-04T06:56:33.687347Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"'''images = random.choice(train_images)\nplt.imshow(images, cmap='Greys_r')'''","metadata":{"execution":{"iopub.status.busy":"2022-08-04T06:56:37.195223Z","iopub.execute_input":"2022-08-04T06:56:37.196353Z","iopub.status.idle":"2022-08-04T06:56:37.395976Z","shell.execute_reply.started":"2022-08-04T06:56:37.196307Z","shell.execute_reply":"2022-08-04T06:56:37.394973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"'''transformation = {\n    'rotate anticlockwise': anticlockwise_rotation,\n    'rotate clockwise': clockwise_rotation,\n    'horizontal flip' : horizontal_flip,\n    'vertical flip' : vertical_flip,\n    'adding noise' : add_noise,\n    'blurring image'  : blur_image\n}\naugmented_images = []\nimages_to_generate = 1000\ni=1\nwhile i<=images_to_generate:\n    image_index = random.randint(0,len(train_images))\n    images = train_images[image_index]\n   # transformed_image=None\n    n = 0\n    transformation_count = random.randint(1, len(transformation))\n    \n    while n <= transformation_count:\n        key = random.choice(list(transformation))\n        transformed_image = transformation[key](images)\n        n=n+1\n    augmented_images.append(transformed_image)\n    i=i+1\n        \n'''","metadata":{"execution":{"iopub.status.busy":"2022-08-04T06:57:02.269965Z","iopub.execute_input":"2022-08-04T06:57:02.270729Z","iopub.status.idle":"2022-08-04T06:57:02.873545Z","shell.execute_reply.started":"2022-08-04T06:57:02.270689Z","shell.execute_reply":"2022-08-04T06:57:02.872585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Implementing the Data augmentation using library\n\nfrom keras.preprocessing.image import ImageDataGenerator\n\ndataset = ImageDataGenerator(featurewise_center=False,\n    samplewise_center=False,\n    featurewise_std_normalization=False,\n    samplewise_std_normalization=False,\n    zca_whitening=False,\n    rotation_range=15,\n    width_shift_range=0.1,\n    height_shift_range=0.1,\n    zoom_range=0.02,\n    horizontal_flip=False,\n    vertical_flip=False,\n    \n)\ntrain_generated = dataset.flow(x_train, y_train, batch_size=128)\ntest_generated = dataset.flow(x_test, y_test, batch_size=128)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:33:59.010200Z","iopub.execute_input":"2022-08-04T09:33:59.010599Z","iopub.status.idle":"2022-08-04T09:33:59.702361Z","shell.execute_reply.started":"2022-08-04T09:33:59.010567Z","shell.execute_reply":"2022-08-04T09:33:59.700985Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"'''plt.imshow(augmented_images[random.randint(0,len(augmented_images))], cmap='Greys_r')'''","metadata":{"execution":{"iopub.status.busy":"2022-08-04T06:57:06.149547Z","iopub.execute_input":"2022-08-04T06:57:06.150045Z","iopub.status.idle":"2022-08-04T06:57:06.390394Z","shell.execute_reply.started":"2022-08-04T06:57:06.150003Z","shell.execute_reply":"2022-08-04T06:57:06.389291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(type(train_images))","metadata":{"execution":{"iopub.status.busy":"2022-08-04T06:57:56.351696Z","iopub.execute_input":"2022-08-04T06:57:56.352081Z","iopub.status.idle":"2022-08-04T06:57:56.357660Z","shell.execute_reply.started":"2022-08-04T06:57:56.352050Z","shell.execute_reply":"2022-08-04T06:57:56.356537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Model Training","metadata":{}},{"cell_type":"code","source":"# Model part \nimport tensorflow as tf\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Activation, Conv2D, MaxPooling2D, Flatten, Dropout, BatchNormalization , GlobalMaxPool2D\nfrom tensorflow.keras import models, layers\nmodel = Sequential()\n\n# Block 1 \nmodel.add(Conv2D(input_shape=(28 , 28 , 1),filters=64, kernel_size=(3, 3), activation=\"relu\", padding=\"same\"))\n#model.add(Activation('relu'))\nmodel.add(BatchNormalization())\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\n#model.add(Dropout(0.2))\n\n# Block 2\nmodel.add(Conv2D(filters=64, kernel_size=(3, 3), activation=\"relu\", padding=\"same\"))\n#model.add(Activation('relu'))\nmodel.add(BatchNormalization())\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\n#model.add(Dropout(0.2))\n\n# Block 3 \nmodel.add(Conv2D(filters=128, kernel_size=(3, 3), activation=\"relu\", padding=\"same\"))\n#model.add(Activation('relu'))\nmodel.add(BatchNormalization())\nmodel.add(MaxPooling2D())\n#model.add(Dropout(0.2))\n\n# Block 4 \nmodel.add(Conv2D(filters=256, kernel_size = (3,3), activation=\"relu\", padding=\"same\"))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\nmodel.add(BatchNormalization())\n\nmodel.add(Flatten())\n#model.add(GlobalMaxPool2D())\nmodel.add(Dense(512,activation=\"relu\"))\n#model.add(Dense(units=64))\n#model.add(Activation('relu'))\n#model.add(Dropout(0.2))\n\nmodel.add(Dense(10,activation=\"sigmoid\"))","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:34:07.241157Z","iopub.execute_input":"2022-08-04T09:34:07.241531Z","iopub.status.idle":"2022-08-04T09:34:11.539362Z","shell.execute_reply.started":"2022-08-04T09:34:07.241501Z","shell.execute_reply":"2022-08-04T09:34:11.537942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(model.summary())","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:34:18.583210Z","iopub.execute_input":"2022-08-04T09:34:18.583836Z","iopub.status.idle":"2022-08-04T09:34:18.598082Z","shell.execute_reply.started":"2022-08-04T09:34:18.583777Z","shell.execute_reply":"2022-08-04T09:34:18.595884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(\n    loss='binary_crossentropy',\n    optimizer='adam',\n    metrics=['accuracy']\n)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:34:27.174624Z","iopub.execute_input":"2022-08-04T09:34:27.175053Z","iopub.status.idle":"2022-08-04T09:34:27.188972Z","shell.execute_reply.started":"2022-08-04T09:34:27.175020Z","shell.execute_reply":"2022-08-04T09:34:27.187779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Train the model\nbatch_size = 128\nepochs =100\ntrain_steps = x_train.shape[0] // batch_size\nvalid_steps = x_test.shape[0] // batch_size\nearly_stop = tf.keras.callbacks.EarlyStopping(\n    monitor=\"val_acc\",\n    verbose=1,\n    mode=\"max\",\n    baseline=None,\n    restore_best_weights=True,\n)\nreduce_plateau = tf.keras.callbacks.ReduceLROnPlateau(\n    monitor=\"val_acc\",\n    factor=0.2,\n    patience=3,\n    verbose=1,\n    mode=\"max\",\n    min_delta=0.0001,\n)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:34:30.780586Z","iopub.execute_input":"2022-08-04T09:34:30.781095Z","iopub.status.idle":"2022-08-04T09:34:30.789369Z","shell.execute_reply.started":"2022-08-04T09:34:30.781063Z","shell.execute_reply":"2022-08-04T09:34:30.787885Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit_generator(train_generated, \n                              epochs = epochs, \n                              steps_per_epoch = train_steps,\n                              validation_data = test_generated,\n                              validation_steps = valid_steps, \n                              callbacks=[early_stop, reduce_plateau])","metadata":{"execution":{"iopub.status.busy":"2022-08-04T09:34:35.875254Z","iopub.execute_input":"2022-08-04T09:34:35.875707Z","iopub.status.idle":"2022-08-04T10:05:38.709420Z","shell.execute_reply.started":"2022-08-04T09:34:35.875678Z","shell.execute_reply":"2022-08-04T10:05:38.708151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Evaluating the Model","metadata":{}},{"cell_type":"code","source":"from keras.utils.vis_utils import plot_model\nplot_model(model, to_file='CNN_model_arch.png', show_shapes=True, show_layer_names=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T10:14:51.209484Z","iopub.execute_input":"2022-08-04T10:14:51.210206Z","iopub.status.idle":"2022-08-04T10:14:52.806541Z","shell.execute_reply.started":"2022-08-04T10:14:51.210161Z","shell.execute_reply":"2022-08-04T10:14:52.804947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import confusion_matrix","metadata":{"execution":{"iopub.status.busy":"2022-08-04T10:15:58.282048Z","iopub.execute_input":"2022-08-04T10:15:58.282513Z","iopub.status.idle":"2022-08-04T10:15:58.465779Z","shell.execute_reply.started":"2022-08-04T10:15:58.282475Z","shell.execute_reply":"2022-08-04T10:15:58.464515Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plot the loss and accuracy curves for training and validation \nfig, ax = plt.subplots(2,1, figsize=(18, 10))\nax[0].plot(history.history['loss'], color='b', label=\"Training loss\")\nax[0].plot(history.history['val_loss'], color='g', label=\"validation loss\",axes =ax[0])\nlegend = ax[0].legend(loc='best', shadow=True)\n\nax[1].plot(history.history['accuracy'], color='b', label=\"Training accuracy\")\nax[1].plot(history.history['val_accuracy'], color='r',label=\"Validation accuracy\")\nlegend = ax[1].legend(loc='best', shadow=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T10:17:51.650010Z","iopub.execute_input":"2022-08-04T10:17:51.650588Z","iopub.status.idle":"2022-08-04T10:17:52.072513Z","shell.execute_reply.started":"2022-08-04T10:17:51.650538Z","shell.execute_reply":"2022-08-04T10:17:52.070908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Prediction \n\ny_pred = model.predict(x_test)\nX_test__ = x_test.reshape(x_test.shape[0], 28, 28)\n\nfig, axis = plt.subplots(4, 4, figsize=(12, 14))\nfor i, ax in enumerate(axis.flat):\n    ax.imshow(X_test__[i], cmap='binary')\n    ax.set(title = f\"Real Number is {y_test[i].argmax()}\\nPredict Number is {y_pred[i].argmax()}\");","metadata":{"execution":{"iopub.status.busy":"2022-08-04T10:19:24.646429Z","iopub.execute_input":"2022-08-04T10:19:24.646901Z","iopub.status.idle":"2022-08-04T10:19:27.728176Z","shell.execute_reply.started":"2022-08-04T10:19:24.646824Z","shell.execute_reply":"2022-08-04T10:19:27.726060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Predictions 2\n\n#estImages, testLabels = generateData(r'/kaggle/input/digit-recognizer/test.csv')\npredictions = model.predict(test_images, verbose=2)\nprint(predictions)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T10:41:57.139708Z","iopub.execute_input":"2022-08-04T10:41:57.140432Z","iopub.status.idle":"2022-08-04T10:41:59.227858Z","shell.execute_reply.started":"2022-08-04T10:41:57.140396Z","shell.execute_reply":"2022-08-04T10:41:59.226522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictionsLabel = np.argmax(predictions, axis=1)\nprint(type(predictionsLabel), len(predictionsLabel), predictionsLabel.shape, predictionsLabel)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T10:42:03.417018Z","iopub.execute_input":"2022-08-04T10:42:03.417424Z","iopub.status.idle":"2022-08-04T10:42:03.426074Z","shell.execute_reply.started":"2022-08-04T10:42:03.417391Z","shell.execute_reply":"2022-08-04T10:42:03.424517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.DataFrame({'ImageId': [i for i in range(1,len(predictionsLabel)+1)], 'Label': predictionsLabel})\ndf","metadata":{"execution":{"iopub.status.busy":"2022-08-04T10:42:05.435653Z","iopub.execute_input":"2022-08-04T10:42:05.436096Z","iopub.status.idle":"2022-08-04T10:42:05.464660Z","shell.execute_reply.started":"2022-08-04T10:42:05.436063Z","shell.execute_reply":"2022-08-04T10:42:05.463150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.to_csv('/kaggle/working/submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-04T11:48:19.681366Z","iopub.execute_input":"2022-08-04T11:48:19.681840Z","iopub.status.idle":"2022-08-04T11:48:19.726183Z","shell.execute_reply.started":"2022-08-04T11:48:19.681802Z","shell.execute_reply":"2022-08-04T11:48:19.724602Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save('/kaggle/working')","metadata":{"execution":{"iopub.status.busy":"2022-08-04T11:48:33.333749Z","iopub.execute_input":"2022-08-04T11:48:33.334234Z","iopub.status.idle":"2022-08-04T11:48:37.051923Z","shell.execute_reply.started":"2022-08-04T11:48:33.334202Z","shell.execute_reply":"2022-08-04T11:48:37.050546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}