{"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 # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n# ignore warning messages\nimport warnings\nwarnings.filterwarnings('ignore')\n\nfrom sklearn.model_selection import train_test_split\nfrom tensorflow import keras\nimport tensorflow as tf\nfrom keras.models import Model\nfrom keras.layers import Input, Lambda, Dense, Flatten,Dropout\nfrom keras.applications.vgg16 import VGG16\nfrom keras.applications.vgg16 import preprocess_input\nfrom keras.preprocessing import image\nfrom keras.preprocessing.image import ImageDataGenerator\nfrom keras.models import Sequential\nfrom keras.models import load_model\nimport numpy as np\nfrom glob import glob\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport os\nimport random\nimport zipfile\n\n","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:28:57.716832Z","iopub.execute_input":"2022-08-31T08:28:57.717202Z","iopub.status.idle":"2022-08-31T08:28:57.726356Z","shell.execute_reply.started":"2022-08-31T08:28:57.717171Z","shell.execute_reply":"2022-08-31T08:28:57.725289Z"},"trusted":true},"execution_count":null,"outputs":[]},{"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\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-31T08:08:25.560989Z","iopub.execute_input":"2022-08-31T08:08:25.561659Z","iopub.status.idle":"2022-08-31T08:08:31.140470Z","shell.execute_reply.started":"2022-08-31T08:08:25.561625Z","shell.execute_reply":"2022-08-31T08:08:31.139286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir(\"../input/dogs-vs-cats/\")","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:08:31.145154Z","iopub.execute_input":"2022-08-31T08:08:31.145929Z","iopub.status.idle":"2022-08-31T08:08:31.161138Z","shell.execute_reply.started":"2022-08-31T08:08:31.145891Z","shell.execute_reply":"2022-08-31T08:08:31.160127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Preparing the data","metadata":{}},{"cell_type":"code","source":"# code from : https://www.kaggle.com/code/nirmit19/cats-vs-dogs-vgg-19\ntrain_path = \"../input/dogs-vs-cats/train.zip\"\ntest_path = \"../input/dogs-vs-cats/test1.zip\"\n\nfiles = \"/kaggle/files/unzipped/\"\n\nwith zipfile.ZipFile(train_path, 'r') as zipp:\n    zipp.extractall(files)\n    \nwith zipfile.ZipFile(test_path, 'r') as zipp:\n    zipp.extractall(files)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:08:32.857795Z","iopub.execute_input":"2022-08-31T08:08:32.858178Z","iopub.status.idle":"2022-08-31T08:08:52.221221Z","shell.execute_reply.started":"2022-08-31T08:08:32.858147Z","shell.execute_reply":"2022-08-31T08:08:52.219794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.DataFrame({\"file\": os.listdir(\"/kaggle/files/unzipped/train\")})\ntrain_df[\"label\"] = train_df[\"file\"].apply(lambda x: x.split(\".\")[0])\n\ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:08:52.228268Z","iopub.execute_input":"2022-08-31T08:08:52.232043Z","iopub.status.idle":"2022-08-31T08:08:52.302556Z","shell.execute_reply.started":"2022-08-31T08:08:52.231966Z","shell.execute_reply":"2022-08-31T08:08:52.301658Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.DataFrame({\"file\": os.listdir(\"/kaggle/files/unzipped/test1\")})\n\ntest_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:08:52.303866Z","iopub.execute_input":"2022-08-31T08:08:52.304243Z","iopub.status.idle":"2022-08-31T08:08:52.895385Z","shell.execute_reply.started":"2022-08-31T08:08:52.304210Z","shell.execute_reply":"2022-08-31T08:08:52.894228Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize = (6, 6))\n\nsns.countplot(x = \"label\", data = train_df, ax = ax)\n\nax.set_title(\"Distribution of Class Labels\")\nsns.despine()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:08:52.901282Z","iopub.execute_input":"2022-08-31T08:08:52.902282Z","iopub.status.idle":"2022-08-31T08:08:53.230051Z","shell.execute_reply.started":"2022-08-31T08:08:52.902240Z","shell.execute_reply":"2022-08-31T08:08:53.228762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Train data samples\n\nW = 5\nH = 5\nfig, ax = plt.subplots(W, H, figsize = (17,17))\nax = ax.ravel() # flaten the matrix into array\nfor i in np.arange(0, W * H): \n    label ='NORMAL'\n    class_dir = os.path.join(\"/kaggle/files/unzipped/train\")\n    # Select a random image\n    image = random.choice(os.listdir(class_dir))\n    # read and display an image with the selected index    \n    img = plt.imread(os.path.join(class_dir,image))\n    ax[i].imshow( img )\n    ax[i].set_title(label, fontsize = 8) # the label\n    ax[i].axis('off')","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:08:53.235947Z","iopub.execute_input":"2022-08-31T08:08:53.239542Z","iopub.status.idle":"2022-08-31T08:08:58.880169Z","shell.execute_reply.started":"2022-08-31T08:08:53.239497Z","shell.execute_reply":"2022-08-31T08:08:58.878455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Test data samples\n\nW = 5\nH = 5\nfig, ax = plt.subplots(W, H, figsize = (17,17))\n\nax = ax.ravel() # flaten the matrix into array\nfor i in np.arange(0, W * H): \n    label ='NORMAL'\n    class_dir = os.path.join(\"/kaggle/files/unzipped/test1\")\n    # Select a random image\n    image = random.choice(os.listdir(class_dir))\n    # read and display an image with the selected index    \n    img = plt.imread(os.path.join(class_dir,image))\n    ax[i].imshow( img )\n    ax[i].set_title(label, fontsize = 8) # the label\n    ax[i].axis('off')","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:08:58.881284Z","iopub.execute_input":"2022-08-31T08:08:58.881591Z","iopub.status.idle":"2022-08-31T08:09:02.102848Z","shell.execute_reply.started":"2022-08-31T08:08:58.881563Z","shell.execute_reply":"2022-08-31T08:09:02.101665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data, val_data = train_test_split(train_df, \n                                        test_size = 0.2, \n                                        stratify = train_df[\"label\"], \n                                        random_state = 666)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:09:02.104473Z","iopub.execute_input":"2022-08-31T08:09:02.104974Z","iopub.status.idle":"2022-08-31T08:09:02.161205Z","shell.execute_reply.started":"2022-08-31T08:09:02.104941Z","shell.execute_reply":"2022-08-31T08:09:02.160089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(rescale=1./255,\n                                     rotation_range=0.4,\n                                     zoom_range=0.2,\n                                     width_shift_range=0.2,\n                                     height_shift_range=0.2,\n                                     shear_range=0.2,\n                                     horizontal_flip=True,\n                                     brightness_range=[0.6,0.9],\n                                     fill_mode='nearest',\n)\n\ntrain_generator = train_datagen.flow_from_dataframe(\n    dataframe = train_data,\n    directory = files + \"train/\",\n    x_col = \"file\",\n    y_col = \"label\",\n    class_mode = \"categorical\",\n    target_size = (224, 224),\n    batch_size = 128,\n    seed = 666)\n                                                      \nvalidation_datagen = ImageDataGenerator(rescale=1./255)\n\nvalidation_generator = validation_datagen.flow_from_dataframe(\n    dataframe = val_data,\n    directory = files + \"train/\",\n    x_col = \"file\",\n    y_col = \"label\",\n    class_mode = \"categorical\",\n    target_size = (224, 224),\n    batch_size = 128,\n    seed = 666,\n    shuffle = False)\n","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:09:02.162805Z","iopub.execute_input":"2022-08-31T08:09:02.163708Z","iopub.status.idle":"2022-08-31T08:09:03.209296Z","shell.execute_reply.started":"2022-08-31T08:09:02.163672Z","shell.execute_reply":"2022-08-31T08:09:03.208179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Models","metadata":{}},{"cell_type":"code","source":"def create_cnn_model():\n\n    model = tf.keras.models.Sequential([ \n      tf.keras.layers.Conv2D(32,(3,3),activation='relu',input_shape=(224,224,3)),\n      tf.keras.layers.MaxPooling2D(2,2),\n      tf.keras.layers.BatchNormalization(),\n      tf.keras.layers.Dropout(0.2),\n\n      tf.keras.layers.Conv2D(64,(3,3),activation='relu'),\n      tf.keras.layers.MaxPooling2D(2,2),\n      tf.keras.layers.Dropout(0.2),\n\n      tf.keras.layers.Conv2D(128,(3,3),activation='relu'),\n      tf.keras.layers.MaxPooling2D(2,2),\n      tf.keras.layers.Dropout(0.2),\n\n      tf.keras.layers.Flatten(),\n      tf.keras.layers.Dense(512,activation='relu'),\n      tf.keras.layers.Dropout(0.5),\n      tf.keras.layers.Dense(128,activation='relu'),\n      tf.keras.layers.Dense(2,activation='sigmoid')  \n    ])\n\n\n    model.compile(optimizer='adam',\n                loss='categorical_crossentropy',\n                metrics=['accuracy']) \n\n\n    return model","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:09:03.211008Z","iopub.execute_input":"2022-08-31T08:09:03.211409Z","iopub.status.idle":"2022-08-31T08:09:03.224492Z","shell.execute_reply.started":"2022-08-31T08:09:03.211371Z","shell.execute_reply":"2022-08-31T08:09:03.223113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cnn_model = create_cnn_model()\ncnn_model.summary()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:09:03.228381Z","iopub.execute_input":"2022-08-31T08:09:03.228659Z","iopub.status.idle":"2022-08-31T08:09:06.221714Z","shell.execute_reply.started":"2022-08-31T08:09:03.228635Z","shell.execute_reply":"2022-08-31T08:09:06.220706Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Train the model\ncnn_train = cnn_model.fit(train_generator,\n                    epochs=1,\n                    verbose=True,\n                    validation_data=validation_generator,\n                    steps_per_epoch= 100,\n                    validation_steps= 20)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:31:20.519186Z","iopub.execute_input":"2022-08-31T07:31:20.520443Z","iopub.status.idle":"2022-08-31T07:32:54.619177Z","shell.execute_reply.started":"2022-08-31T07:31:20.520402Z","shell.execute_reply":"2022-08-31T07:32:54.617165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## ResNet 50","metadata":{}},{"cell_type":"code","source":"from tensorflow.keras.applications import ResNet50\n\nresnet_50 = Sequential()\n\nresnet_50.add(ResNet50(include_top = False, pooling = 'avg', weights = 'imagenet')) # ,input_shape=(224,224,3)\n\nresnet_50.add(Dense(1024, activation = 'relu'))\nresnet_50.add(Dense(512, activation = 'relu'))\nresnet_50.add(Dense(128, activation = 'relu'))\nresnet_50.add(Dense(64, activation = 'relu'))\nresnet_50.add(Dense(2, activation = 'sigmoid'))\n\n# Say not to train first layer (ResNet) model as it is already trained\nresnet_50.layers[0].trainable = False","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:47:36.918670Z","iopub.execute_input":"2022-08-31T07:47:36.919059Z","iopub.status.idle":"2022-08-31T07:47:38.973988Z","shell.execute_reply.started":"2022-08-31T07:47:36.919025Z","shell.execute_reply":"2022-08-31T07:47:38.973001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"resnet_50.summary()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:47:46.265983Z","iopub.execute_input":"2022-08-31T07:47:46.266374Z","iopub.status.idle":"2022-08-31T07:47:46.283756Z","shell.execute_reply.started":"2022-08-31T07:47:46.266342Z","shell.execute_reply":"2022-08-31T07:47:46.282731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras import optimizers\nresnet_50.compile(optimizer = keras.optimizers.Adam(learning_rate=0.001), \n                  loss = keras.losses.CategoricalCrossentropy(from_logits = True), \n                  metrics = ['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:47:51.861239Z","iopub.execute_input":"2022-08-31T07:47:51.861621Z","iopub.status.idle":"2022-08-31T07:47:51.875166Z","shell.execute_reply.started":"2022-08-31T07:47:51.861590Z","shell.execute_reply":"2022-08-31T07:47:51.874232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"resnet_history = resnet_50.fit_generator(\n        train_generator,\n        steps_per_epoch=50,\n        epochs = 5,\n        validation_data=validation_generator,\n        validation_steps=20\n)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:47:55.608882Z","iopub.execute_input":"2022-08-31T07:47:55.609246Z","iopub.status.idle":"2022-08-31T07:51:25.421571Z","shell.execute_reply.started":"2022-08-31T07:47:55.609215Z","shell.execute_reply":"2022-08-31T07:51:25.420490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## VGG ","metadata":{}},{"cell_type":"code","source":"vgg = VGG16(input_shape=[224,224] + [3], weights='imagenet',pooling = 'avg', include_top=False)\nfor layer in vgg.layers:\n    layer.trainable = False","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:26:49.122106Z","iopub.execute_input":"2022-08-31T08:26:49.122720Z","iopub.status.idle":"2022-08-31T08:26:49.418214Z","shell.execute_reply.started":"2022-08-31T08:26:49.122684Z","shell.execute_reply":"2022-08-31T08:26:49.417192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# create a model object\nVGG_model = Sequential([\n            vgg,\n        Dense(100,activation='relu'),\n        Dropout(0.4),\n        Dense(64,activation='relu'),\n        Dense(2,activation='softmax')\n    ])\n\n# view the structure of the model\nVGG_model.summary()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:29:07.225714Z","iopub.execute_input":"2022-08-31T08:29:07.226082Z","iopub.status.idle":"2022-08-31T08:29:07.305737Z","shell.execute_reply.started":"2022-08-31T08:29:07.226051Z","shell.execute_reply":"2022-08-31T08:29:07.304697Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"VGG_model.compile(\n  loss='categorical_crossentropy',\n  optimizer='adam',\n  metrics=['accuracy']\n)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:31:17.704641Z","iopub.execute_input":"2022-08-31T08:31:17.705241Z","iopub.status.idle":"2022-08-31T08:31:17.717431Z","shell.execute_reply.started":"2022-08-31T08:31:17.705205Z","shell.execute_reply":"2022-08-31T08:31:17.716450Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"batch_size=128\nvgg_history_1 = VGG_model.fit(train_generator,\n                    epochs=2,\n                    verbose=1,\n                    validation_data=validation_generator,\n                    steps_per_epoch=train_data.shape[0] // batch_size,\n                    validation_steps=val_data.shape[0] // batch_size)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:31:21.075372Z","iopub.execute_input":"2022-08-31T08:31:21.075728Z","iopub.status.idle":"2022-08-31T08:43:09.138045Z","shell.execute_reply.started":"2022-08-31T08:31:21.075689Z","shell.execute_reply":"2022-08-31T08:43:09.137033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(vgg_history_1.history['accuracy'], label='accuracy')\nplt.plot(vgg_history_1.history['val_accuracy'], label = 'val_accuracy')\nplt.xlabel('Epoch')\nplt.ylabel('Accuracy')\nplt.ylim([0.5, 1])\nplt.legend(loc='lower right')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:47:05.666441Z","iopub.execute_input":"2022-08-31T08:47:05.666805Z","iopub.status.idle":"2022-08-31T08:47:05.857036Z","shell.execute_reply.started":"2022-08-31T08:47:05.666773Z","shell.execute_reply":"2022-08-31T08:47:05.855944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## save model\n# from keras.models import load_model\n# import pickle\n# VGG_model.save('cat_dog_vgg.h5')\n## save the model 'pickle'\n# filename = 'the path'\n# pickle.dump(VGG_model, open(filename, 'wb'))","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:34:07.284041Z","iopub.execute_input":"2022-08-31T09:34:07.284703Z","iopub.status.idle":"2022-08-31T09:34:07.490153Z","shell.execute_reply.started":"2022-08-31T09:34:07.284667Z","shell.execute_reply":"2022-08-31T09:34:07.488948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# prepare test data for prediction","metadata":{}},{"cell_type":"code","source":"testing = validation_datagen.flow_from_dataframe(\n    dataframe = test_df,\n    directory = files + \"test1/\",\n    x_col = \"file\",\n    y_col = None,\n    class_mode = None,\n    target_size = (224, 224),\n    batch_size = 128,\n    seed = 666,\n    shuffle = True)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:53:40.822719Z","iopub.execute_input":"2022-08-31T08:53:40.823339Z","iopub.status.idle":"2022-08-31T08:53:40.934385Z","shell.execute_reply.started":"2022-08-31T08:53:40.823304Z","shell.execute_reply":"2022-08-31T08:53:40.933354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Predict using vgg model","metadata":{}},{"cell_type":"code","source":"prediction = VGG_model.predict(testing)\nprediction","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:01:14.576908Z","iopub.execute_input":"2022-08-31T09:01:14.577809Z","iopub.status.idle":"2022-08-31T09:02:02.011966Z","shell.execute_reply.started":"2022-08-31T09:01:14.577761Z","shell.execute_reply":"2022-08-31T09:02:02.010988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# submit results","metadata":{}},{"cell_type":"code","source":"submit_label=np.argmax(prediction,axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:22:12.703522Z","iopub.execute_input":"2022-08-31T09:22:12.704121Z","iopub.status.idle":"2022-08-31T09:22:12.709470Z","shell.execute_reply.started":"2022-08-31T09:22:12.704084Z","shell.execute_reply":"2022-08-31T09:22:12.708319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit_label","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:23:31.072854Z","iopub.execute_input":"2022-08-31T09:23:31.076160Z","iopub.status.idle":"2022-08-31T09:23:31.085450Z","shell.execute_reply.started":"2022-08-31T09:23:31.076084Z","shell.execute_reply":"2022-08-31T09:23:31.083996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv('../input/dogs-vs-cats/sampleSubmission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-31T08:58:29.025679Z","iopub.execute_input":"2022-08-31T08:58:29.026416Z","iopub.status.idle":"2022-08-31T08:58:29.048342Z","shell.execute_reply.started":"2022-08-31T08:58:29.026379Z","shell.execute_reply":"2022-08-31T08:58:29.047358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_label(number):\n    labels = {0:'Cat', 1:'Dog'}\n    return labels[number]\n","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:40:07.431433Z","iopub.execute_input":"2022-08-31T09:40:07.432161Z","iopub.status.idle":"2022-08-31T09:40:07.437072Z","shell.execute_reply.started":"2022-08-31T09:40:07.432124Z","shell.execute_reply":"2022-08-31T09:40:07.435975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels=[]\nfor i in range(len(submit_label)):\n    labels.append(get_label(submit_label[i]))\n","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:40:11.010508Z","iopub.execute_input":"2022-08-31T09:40:11.011260Z","iopub.status.idle":"2022-08-31T09:40:11.025644Z","shell.execute_reply.started":"2022-08-31T09:40:11.011171Z","shell.execute_reply":"2022-08-31T09:40:11.024452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result = pd.DataFrame(\n    {\n        'id':np.arange(1,len(submit_label)+1),\n        'label':labels\n    }\n)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:40:40.875901Z","iopub.execute_input":"2022-08-31T09:40:40.876496Z","iopub.status.idle":"2022-08-31T09:40:40.884931Z","shell.execute_reply.started":"2022-08-31T09:40:40.876460Z","shell.execute_reply":"2022-08-31T09:40:40.883671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:40:43.828786Z","iopub.execute_input":"2022-08-31T09:40:43.829573Z","iopub.status.idle":"2022-08-31T09:40:43.844000Z","shell.execute_reply.started":"2022-08-31T09:40:43.829524Z","shell.execute_reply":"2022-08-31T09:40:43.842942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_result = pd.DataFrame(\n    {\n        'id':np.arange(1,len(submit_label)+1),\n        'label':submit_label\n    }\n)\n","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:41:02.117830Z","iopub.execute_input":"2022-08-31T09:41:02.118195Z","iopub.status.idle":"2022-08-31T09:41:02.124302Z","shell.execute_reply.started":"2022-08-31T09:41:02.118165Z","shell.execute_reply":"2022-08-31T09:41:02.123250Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_result","metadata":{"execution":{"iopub.status.busy":"2022-08-31T09:41:04.459638Z","iopub.execute_input":"2022-08-31T09:41:04.460000Z","iopub.status.idle":"2022-08-31T09:41:04.471827Z","shell.execute_reply.started":"2022-08-31T09:41:04.459968Z","shell.execute_reply":"2022-08-31T09:41:04.470686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}