{"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":"2023-07-30T04:56:28.374386Z","iopub.execute_input":"2023-07-30T04:56:28.37482Z","iopub.status.idle":"2023-07-30T04:56:28.385136Z","shell.execute_reply.started":"2023-07-30T04:56:28.374789Z","shell.execute_reply":"2023-07-30T04:56:28.383639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"/kaggle/input/dogs-vs-cats/test1.zip\n/kaggle/input/dogs-vs-cats/train.zip\n/kaggle/input/dogs-vs-cats/sampleSubmission.csv","metadata":{}},{"cell_type":"code","source":"\nimport numpy as np\nimport pandas as pd \n\nimport matplotlib.pyplot as plt\nimport matplotlib.image as img\n%matplotlib inline\nimport seaborn as sns\nfrom PIL import Image, ImageFilter, ImageEnhance\nimport cv2\n\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom tensorflow.keras import layers\nfrom tensorflow.keras.layers.experimental import preprocessing\nimport os\nfrom numpy import asarray\n\nimport zipfile\n\nzip_files = ['test1', 'train']\n\nfor zip_file in zip_files:\n    with zipfile.ZipFile(\"../input/dogs-vs-cats/{}.zip\".format(zip_file),\"r\") as z:\n        z.extractall(\".\")\n        print(\"{} unzipped\".format(zip_file))","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:28.388343Z","iopub.execute_input":"2023-07-30T04:56:28.38897Z","iopub.status.idle":"2023-07-30T04:56:47.167115Z","shell.execute_reply.started":"2023-07-30T04:56:28.388923Z","shell.execute_reply":"2023-07-30T04:56:47.165938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"/opt/conda/lib/python3.10/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.5\n  warnings.warn(f\"A NumPy version >={np_minversion} and <{np_maxversion}\"\n/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']\ncaused by: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZN3tsl6StatusC1EN10tensorflow5error4CodeESt17basic_string_viewIcSt11char_traitsIcEENS_14SourceLocationE']\n  warnings.warn(f\"unable to load libtensorflow_io_plugins.so: {e}\")\n/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io.so']\ncaused by: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io.so: undefined symbol: _ZTVN10tensorflow13GcsFileSystemE']\n  warnings.warn(f\"file system plugins are not loaded: {e}\")\ntest1 unzipped\ntrain unzipped\n","metadata":{}},{"cell_type":"code","source":"TRAIN_DIR_PATH = './train'\nfile_names = os.listdir(TRAIN_DIR_PATH)\nprint('There are {} number of images in directory.'.format(len(file_names)))","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.168503Z","iopub.execute_input":"2023-07-30T04:56:47.168823Z","iopub.status.idle":"2023-07-30T04:56:47.192284Z","shell.execute_reply.started":"2023-07-30T04:56:47.168795Z","shell.execute_reply":"2023-07-30T04:56:47.191176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"There are 25000 number of images in directory.","metadata":{}},{"cell_type":"code","source":"#import numpy as np\n#import pandas as pd \n#from keras.preprocessing.image \n#from tensorflow.keras.utils import load_img\n#import ImageDataGenerator, load_img\n#from keras.utils import to_categorical\n#from sklearn.model_selection import train_test_split\n#import matplotlib.pyplot as plt\n#import random\n#import os\n#print(os.listdir(\"../input\"))","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.195143Z","iopub.execute_input":"2023-07-30T04:56:47.195482Z","iopub.status.idle":"2023-07-30T04:56:47.200533Z","shell.execute_reply.started":"2023-07-30T04:56:47.195454Z","shell.execute_reply":"2023-07-30T04:56:47.199321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"FAST_RUN = False\nIMAGE_WIDTH=128\nIMAGE_HEIGHT=128\nIMAGE_SIZE=(IMAGE_WIDTH, IMAGE_HEIGHT)\nIMAGE_CHANNELS=3","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.202486Z","iopub.execute_input":"2023-07-30T04:56:47.202994Z","iopub.status.idle":"2023-07-30T04:56:47.217647Z","shell.execute_reply.started":"2023-07-30T04:56:47.202948Z","shell.execute_reply":"2023-07-30T04:56:47.216428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#filenames = os.listdir(\"../input/train/train\")\nfilenames = os.listdir(TRAIN_DIR_PATH)\ncategories = []\nfor filename in filenames:\n    category = filename.split('.')[0]\n    if category == 'dog':\n        categories.append(1)\n    else:\n        categories.append(0)\n\ndf = pd.DataFrame({\n    'filename': filenames,\n    'category': categories\n})\n\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.219274Z","iopub.execute_input":"2023-07-30T04:56:47.219787Z","iopub.status.idle":"2023-07-30T04:56:47.303649Z","shell.execute_reply.started":"2023-07-30T04:56:47.219744Z","shell.execute_reply":"2023-07-30T04:56:47.302468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.tail()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.305458Z","iopub.execute_input":"2023-07-30T04:56:47.30594Z","iopub.status.idle":"2023-07-30T04:56:47.317634Z","shell.execute_reply.started":"2023-07-30T04:56:47.305898Z","shell.execute_reply":"2023-07-30T04:56:47.316449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['category'].value_counts().plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.319388Z","iopub.execute_input":"2023-07-30T04:56:47.319935Z","iopub.status.idle":"2023-07-30T04:56:47.634509Z","shell.execute_reply.started":"2023-07-30T04:56:47.319893Z","shell.execute_reply":"2023-07-30T04:56:47.633314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample = random.choice(filenames)\n#image = load_img(\"../input/train/train/\"+sample)\nimage = load_img(\"./train/\"+sample)\nplt.imshow(image)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.63626Z","iopub.execute_input":"2023-07-30T04:56:47.63664Z","iopub.status.idle":"2023-07-30T04:56:47.762396Z","shell.execute_reply.started":"2023-07-30T04:56:47.63661Z","shell.execute_reply":"2023-07-30T04:56:47.757793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Conv2D, MaxPooling2D, Dropout, Flatten, Dense, Activation, BatchNormalization\n\nmodel = Sequential()\n\nmodel.add(Conv2D(32, (3, 3), activation='relu', input_shape=(IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_CHANNELS)))\nmodel.add(BatchNormalization())\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Dropout(0.25))\n\nmodel.add(Conv2D(64, (3, 3), activation='relu'))\nmodel.add(BatchNormalization())\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Dropout(0.25))\n\nmodel.add(Conv2D(128, (3, 3), activation='relu'))\nmodel.add(BatchNormalization())\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Dropout(0.25))\n\nmodel.add(Flatten())\nmodel.add(Dense(512, activation='relu'))\nmodel.add(BatchNormalization())\nmodel.add(Dropout(0.5))\nmodel.add(Dense(2, activation='softmax')) # 2 because we have cat and dog classes\n\nmodel.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])\n\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.763511Z","iopub.status.idle":"2023-07-30T04:56:47.763967Z","shell.execute_reply.started":"2023-07-30T04:56:47.763744Z","shell.execute_reply":"2023-07-30T04:56:47.763764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.callbacks import EarlyStopping, ReduceLROnPlateau","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.765637Z","iopub.status.idle":"2023-07-30T04:56:47.766141Z","shell.execute_reply.started":"2023-07-30T04:56:47.765926Z","shell.execute_reply":"2023-07-30T04:56:47.765948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"earlystop = EarlyStopping(patience=10)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.768095Z","iopub.status.idle":"2023-07-30T04:56:47.76866Z","shell.execute_reply.started":"2023-07-30T04:56:47.768382Z","shell.execute_reply":"2023-07-30T04:56:47.768409Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', \n                                            patience=2, \n                                            verbose=1, \n                                            factor=0.5, \n                                            min_lr=0.00001)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.770198Z","iopub.status.idle":"2023-07-30T04:56:47.77076Z","shell.execute_reply.started":"2023-07-30T04:56:47.770464Z","shell.execute_reply":"2023-07-30T04:56:47.77049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"callbacks = [earlystop, learning_rate_reduction]","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.772316Z","iopub.status.idle":"2023-07-30T04:56:47.772689Z","shell.execute_reply.started":"2023-07-30T04:56:47.772505Z","shell.execute_reply":"2023-07-30T04:56:47.772522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"category\"] = df[\"category\"].replace({0: 'cat', 1: 'dog'}) \n\ntrain_df, validate_df = train_test_split(df, test_size=0.20, random_state=42)\ntrain_df = train_df.reset_index(drop=True)\nvalidate_df = validate_df.reset_index(drop=True)\n\ntrain_df['category'].value_counts().plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.774199Z","iopub.status.idle":"2023-07-30T04:56:47.774733Z","shell.execute_reply.started":"2023-07-30T04:56:47.774462Z","shell.execute_reply":"2023-07-30T04:56:47.774487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"validate_df['category'].value_counts().plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.776125Z","iopub.status.idle":"2023-07-30T04:56:47.776711Z","shell.execute_reply.started":"2023-07-30T04:56:47.776513Z","shell.execute_reply":"2023-07-30T04:56:47.776532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_train = train_df.shape[0]\ntotal_validate = validate_df.shape[0]\nbatch_size=15","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.777729Z","iopub.status.idle":"2023-07-30T04:56:47.778139Z","shell.execute_reply.started":"2023-07-30T04:56:47.77793Z","shell.execute_reply":"2023-07-30T04:56:47.777948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(\n    rotation_range=15,\n    rescale=1./255,\n    shear_range=0.1,\n    zoom_range=0.2,\n    horizontal_flip=True,\n    width_shift_range=0.1,\n    height_shift_range=0.1\n)\n\ntrain_generator = train_datagen.flow_from_dataframe(\n    train_df, \n    #\"../input/train/train/\", \n    \"./train/\", \n    x_col='filename',\n    y_col='category',\n    target_size=IMAGE_SIZE,\n    class_mode='categorical',\n    batch_size=batch_size\n)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.779394Z","iopub.status.idle":"2023-07-30T04:56:47.78012Z","shell.execute_reply.started":"2023-07-30T04:56:47.779922Z","shell.execute_reply":"2023-07-30T04:56:47.779942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"validation_datagen = ImageDataGenerator(rescale=1./255)\nvalidation_generator = validation_datagen.flow_from_dataframe(\n    validate_df, \n    #\"../input/train/train/\", \n    \"./train/\", \n    x_col='filename',\n    y_col='category',\n    target_size=IMAGE_SIZE,\n    class_mode='categorical',\n    batch_size=batch_size\n)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.781445Z","iopub.status.idle":"2023-07-30T04:56:47.781809Z","shell.execute_reply.started":"2023-07-30T04:56:47.781627Z","shell.execute_reply":"2023-07-30T04:56:47.781643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"example_df = train_df.sample(n=1).reset_index(drop=True)\nexample_generator = train_datagen.flow_from_dataframe(\n    example_df, \n    #\"../input/train/train/\", \n    \"./train/\", \n    x_col='filename',\n    y_col='category',\n    target_size=IMAGE_SIZE,\n    class_mode='categorical'\n)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.783132Z","iopub.status.idle":"2023-07-30T04:56:47.783515Z","shell.execute_reply.started":"2023-07-30T04:56:47.783333Z","shell.execute_reply":"2023-07-30T04:56:47.783351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12, 12))\nfor i in range(0, 15):\n    plt.subplot(5, 3, i+1)\n    for X_batch, Y_batch in example_generator:\n        image = X_batch[0]\n        plt.imshow(image)\n        break\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.784816Z","iopub.status.idle":"2023-07-30T04:56:47.785211Z","shell.execute_reply.started":"2023-07-30T04:56:47.785017Z","shell.execute_reply":"2023-07-30T04:56:47.785034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"epochs=3 \n#if FAST_RUN else 50\nhistory = model.fit(\n    train_generator, \n    epochs=epochs,\n    validation_data=validation_generator,\n    validation_steps=total_validate//batch_size,\n    steps_per_epoch=total_train//batch_size,\n    callbacks=callbacks\n)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.786562Z","iopub.status.idle":"2023-07-30T04:56:47.78695Z","shell.execute_reply.started":"2023-07-30T04:56:47.78675Z","shell.execute_reply":"2023-07-30T04:56:47.786768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save_weights(\"model.h5\")","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.788369Z","iopub.status.idle":"2023-07-30T04:56:47.788919Z","shell.execute_reply.started":"2023-07-30T04:56:47.788609Z","shell.execute_reply":"2023-07-30T04:56:47.788635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 12))\nax1.plot(history.history['loss'], color='b', label=\"Training loss\")\nax1.plot(history.history['val_loss'], color='r', label=\"validation loss\")\nax1.set_xticks(np.arange(1, epochs, 1))\nax1.set_yticks(np.arange(0, 1, 0.1))\n\nax2.plot(history.history['accuracy'], color='b', label=\"Training accuracy\")\nax2.plot(history.history['val_accuracy'], color='r',label=\"Validation accuracy\")\nax2.set_xticks(np.arange(1, epochs, 1))\nax2.set_yticks(np.arange(0, 1, 0.1))\n\nlegend = plt.legend(loc='best', shadow=True)\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.795213Z","iopub.status.idle":"2023-07-30T04:56:47.79586Z","shell.execute_reply.started":"2023-07-30T04:56:47.795657Z","shell.execute_reply":"2023-07-30T04:56:47.795678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#test_filenames = os.listdir(\"../input/test1/test1\")\ntest_filenames = os.listdir(\"./test1\")\ntest_df = pd.DataFrame({\n    'filename': test_filenames\n})\nnb_samples = test_df.shape[0]","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.797317Z","iopub.status.idle":"2023-07-30T04:56:47.797694Z","shell.execute_reply.started":"2023-07-30T04:56:47.797509Z","shell.execute_reply":"2023-07-30T04:56:47.797526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_gen = ImageDataGenerator(rescale=1./255)\ntest_generator = test_gen.flow_from_dataframe(\n    test_df, \n    #\"../input/test1/test1/\", \n    \"./test1/\", \n    x_col='filename',\n    y_col=None,\n    class_mode=None,\n    target_size=IMAGE_SIZE,\n    batch_size=batch_size,\n    shuffle=False\n)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.798968Z","iopub.status.idle":"2023-07-30T04:56:47.799347Z","shell.execute_reply.started":"2023-07-30T04:56:47.799157Z","shell.execute_reply":"2023-07-30T04:56:47.799174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predict = model.predict(test_generator, steps=np.ceil(nb_samples/batch_size))","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.800503Z","iopub.status.idle":"2023-07-30T04:56:47.800904Z","shell.execute_reply.started":"2023-07-30T04:56:47.800683Z","shell.execute_reply":"2023-07-30T04:56:47.8007Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['category'] = np.argmax(predict, axis=-1)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.802384Z","iopub.status.idle":"2023-07-30T04:56:47.802742Z","shell.execute_reply.started":"2023-07-30T04:56:47.802563Z","shell.execute_reply":"2023-07-30T04:56:47.80258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label_map = dict((v,k) for k,v in train_generator.class_indices.items())\ntest_df['category'] = test_df['category'].replace(label_map)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.803864Z","iopub.status.idle":"2023-07-30T04:56:47.804287Z","shell.execute_reply.started":"2023-07-30T04:56:47.804096Z","shell.execute_reply":"2023-07-30T04:56:47.804114Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['category'] = test_df['category'].replace({ 'dog': 1, 'cat': 0 })","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.805516Z","iopub.status.idle":"2023-07-30T04:56:47.805894Z","shell.execute_reply.started":"2023-07-30T04:56:47.805696Z","shell.execute_reply":"2023-07-30T04:56:47.805713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['category'].value_counts().plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.806828Z","iopub.status.idle":"2023-07-30T04:56:47.807497Z","shell.execute_reply.started":"2023-07-30T04:56:47.807293Z","shell.execute_reply":"2023-07-30T04:56:47.807312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_test = test_df.head(18)\nsample_test.head()\nplt.figure(figsize=(12, 24))\nfor index, row in sample_test.iterrows():\n    filename = row['filename']\n    category = row['category']\n    #img = load_img(\"../input/test1/test1/\"+filename, target_size=IMAGE_SIZE)\n    img = load_img(\"./test1/\"+filename, target_size=IMAGE_SIZE)\n    plt.subplot(6, 3, index+1)\n    plt.imshow(img)\n    plt.xlabel(filename + '(' + \"{}\".format(category) + ')' )\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.808609Z","iopub.status.idle":"2023-07-30T04:56:47.808992Z","shell.execute_reply.started":"2023-07-30T04:56:47.808793Z","shell.execute_reply":"2023-07-30T04:56:47.80881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df = test_df.copy()\nsubmission_df['id'] = submission_df['filename'].str.split('.').str[0]\nsubmission_df['label'] = submission_df['category']\nsubmission_df.drop(['filename', 'category'], axis=1, inplace=True)\nsubmission_df.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2023-07-30T04:56:47.810199Z","iopub.status.idle":"2023-07-30T04:56:47.81057Z","shell.execute_reply.started":"2023-07-30T04:56:47.810388Z","shell.execute_reply":"2023-07-30T04:56:47.810405Z"},"trusted":true},"execution_count":null,"outputs":[]}]}