{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":3362,"databundleVersionId":31148,"sourceType":"competition"}],"dockerImageVersionId":31041,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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","trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:35.811577Z","iopub.execute_input":"2025-05-28T07:41:35.812225Z","iopub.status.idle":"2025-05-28T07:41:35.818531Z","shell.execute_reply.started":"2025-05-28T07:41:35.812200Z","shell.execute_reply":"2025-05-28T07:41:35.817861Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\n# from keras.preprocessing.image import ImageDataGenerator, load_img\nfrom keras.utils import to_categorical\nfrom sklearn.model_selection import train_test_split\nimport matplotlib.pyplot as plt\nimport random\nimport os\nfrom tensorflow.keras.preprocessing.image import load_img\nprint(os.listdir(\"/kaggle/input/dogs-vs-cats\"))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:35.820049Z","iopub.execute_input":"2025-05-28T07:41:35.820650Z","iopub.status.idle":"2025-05-28T07:41:35.834986Z","shell.execute_reply.started":"2025-05-28T07:41:35.820627Z","shell.execute_reply":"2025-05-28T07:41:35.834223Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import zipfile\n\nwith zipfile.ZipFile(\"/kaggle/input/dogs-vs-cats/train.zip\", 'r') as zip_ref:\n    zip_ref.extractall(\"/kaggle/working/train\")\n\nwith zipfile.ZipFile(\"/kaggle/input/dogs-vs-cats/test1.zip\", 'r') as zip_ref:\n    zip_ref.extractall(\"/kaggle/working/test1\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:35.835972Z","iopub.execute_input":"2025-05-28T07:41:35.836256Z","iopub.status.idle":"2025-05-28T07:41:45.012611Z","shell.execute_reply.started":"2025-05-28T07:41:35.836234Z","shell.execute_reply":"2025-05-28T07:41:45.012057Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(os.listdir(\"/kaggle/working/test1\"))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.013419Z","iopub.execute_input":"2025-05-28T07:41:45.013676Z","iopub.status.idle":"2025-05-28T07:41:45.018221Z","shell.execute_reply.started":"2025-05-28T07:41:45.013657Z","shell.execute_reply":"2025-05-28T07:41:45.017567Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(os.listdir(\"/kaggle/working/train\"))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.020383Z","iopub.execute_input":"2025-05-28T07:41:45.021179Z","iopub.status.idle":"2025-05-28T07:41:45.033831Z","shell.execute_reply.started":"2025-05-28T07:41:45.021161Z","shell.execute_reply":"2025-05-28T07:41:45.033154Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"FAST_RUN = False\nIMAGE_WIDTH = 128\nIMAGE_HEIGHT = 128\nIMAGE_SIZE = (IMAGE_WIDTH, IMAGE_HEIGHT)\nIMAGE_CHANNELS = 3 ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.034795Z","iopub.execute_input":"2025-05-28T07:41:45.035074Z","iopub.status.idle":"2025-05-28T07:41:45.049067Z","shell.execute_reply.started":"2025-05-28T07:41:45.035058Z","shell.execute_reply":"2025-05-28T07:41:45.048457Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"filenames = os.listdir('/kaggle/working/train/train')\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})","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.049724Z","iopub.execute_input":"2025-05-28T07:41:45.049942Z","iopub.status.idle":"2025-05-28T07:41:45.094951Z","shell.execute_reply.started":"2025-05-28T07:41:45.049919Z","shell.execute_reply":"2025-05-28T07:41:45.094420Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.095614Z","iopub.execute_input":"2025-05-28T07:41:45.095859Z","iopub.status.idle":"2025-05-28T07:41:45.102618Z","shell.execute_reply.started":"2025-05-28T07:41:45.095835Z","shell.execute_reply":"2025-05-28T07:41:45.101993Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.103231Z","iopub.execute_input":"2025-05-28T07:41:45.103456Z","iopub.status.idle":"2025-05-28T07:41:45.119271Z","shell.execute_reply.started":"2025-05-28T07:41:45.103431Z","shell.execute_reply":"2025-05-28T07:41:45.118540Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df['category'].value_counts().plot.bar()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.120004Z","iopub.execute_input":"2025-05-28T07:41:45.120236Z","iopub.status.idle":"2025-05-28T07:41:45.235258Z","shell.execute_reply.started":"2025-05-28T07:41:45.120212Z","shell.execute_reply":"2025-05-28T07:41:45.234597Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample = random.choice(filenames)\nimage = load_img(\"/kaggle/working/train/train/\"+sample)\nplt.imshow(image)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.235978Z","iopub.execute_input":"2025-05-28T07:41:45.236289Z","iopub.status.idle":"2025-05-28T07:41:45.476707Z","shell.execute_reply.started":"2025-05-28T07:41:45.236269Z","shell.execute_reply":"2025-05-28T07:41:45.476042Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Conv2D, MaxPooling2D, Dropout, Flatten, Dense, Activation, BatchNormalization, Input\n\nmodel = Sequential()\nmodel.add(Input(shape=(IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_CHANNELS)))\nmodel.add(Conv2D(32, (3, 3), activation='relu'))\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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.477581Z","iopub.execute_input":"2025-05-28T07:41:45.477836Z","iopub.status.idle":"2025-05-28T07:41:45.643854Z","shell.execute_reply.started":"2025-05-28T07:41:45.477819Z","shell.execute_reply":"2025-05-28T07:41:45.643146Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.callbacks import EarlyStopping, ReduceLROnPlateau\nearlystop = EarlyStopping(patience=10)\n\nlearning_rate_reduction = ReduceLROnPlateau(monitor='val_accuracy', \n                                            patience=2, \n                                            verbose=1, \n                                            factor=0.5, \n                                            min_lr=0.00001)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.644647Z","iopub.execute_input":"2025-05-28T07:41:45.644865Z","iopub.status.idle":"2025-05-28T07:41:45.648752Z","shell.execute_reply.started":"2025-05-28T07:41:45.644840Z","shell.execute_reply":"2025-05-28T07:41:45.648057Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"callbacks = [earlystop, learning_rate_reduction]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.651914Z","iopub.execute_input":"2025-05-28T07:41:45.652097Z","iopub.status.idle":"2025-05-28T07:41:45.667500Z","shell.execute_reply.started":"2025-05-28T07:41:45.652083Z","shell.execute_reply":"2025-05-28T07:41:45.666873Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df[\"category\"] = df[\"category\"].replace({0: 'cat', 1: 'dog'}) ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.668050Z","iopub.execute_input":"2025-05-28T07:41:45.668206Z","iopub.status.idle":"2025-05-28T07:41:45.683029Z","shell.execute_reply.started":"2025-05-28T07:41:45.668189Z","shell.execute_reply":"2025-05-28T07:41:45.682366Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_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)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.683604Z","iopub.execute_input":"2025-05-28T07:41:45.683764Z","iopub.status.idle":"2025-05-28T07:41:45.700146Z","shell.execute_reply.started":"2025-05-28T07:41:45.683747Z","shell.execute_reply":"2025-05-28T07:41:45.699506Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df['category'].value_counts().plot.bar()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.700705Z","iopub.execute_input":"2025-05-28T07:41:45.700906Z","iopub.status.idle":"2025-05-28T07:41:45.807376Z","shell.execute_reply.started":"2025-05-28T07:41:45.700883Z","shell.execute_reply":"2025-05-28T07:41:45.806708Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"validate_df['category'].value_counts().plot.bar()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.808191Z","iopub.execute_input":"2025-05-28T07:41:45.808418Z","iopub.status.idle":"2025-05-28T07:41:45.911972Z","shell.execute_reply.started":"2025-05-28T07:41:45.808402Z","shell.execute_reply":"2025-05-28T07:41:45.911343Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"total_train = train_df.shape[0]\ntotal_validate = validate_df.shape[0]\nbatch_size=64","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.912616Z","iopub.execute_input":"2025-05-28T07:41:45.912889Z","iopub.status.idle":"2025-05-28T07:41:45.916648Z","shell.execute_reply.started":"2025-05-28T07:41:45.912867Z","shell.execute_reply":"2025-05-28T07:41:45.915834Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from tensorflow.keras.preprocessing.image import ImageDataGenerator, load_img\n\ntrain_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    \"/kaggle/working/train/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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:45.917410Z","iopub.execute_input":"2025-05-28T07:41:45.918190Z","iopub.status.idle":"2025-05-28T07:41:46.071690Z","shell.execute_reply.started":"2025-05-28T07:41:45.918168Z","shell.execute_reply":"2025-05-28T07:41:46.071114Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"validation_datagen = ImageDataGenerator(rescale=1./255)\nvalidation_generator = validation_datagen.flow_from_dataframe(\n    validate_df, \n    \"/kaggle/working/train/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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:46.072307Z","iopub.execute_input":"2025-05-28T07:41:46.072596Z","iopub.status.idle":"2025-05-28T07:41:46.114716Z","shell.execute_reply.started":"2025-05-28T07:41:46.072579Z","shell.execute_reply":"2025-05-28T07:41:46.114156Z"}},"outputs":[],"execution_count":null},{"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    \"/kaggle/working/train/train/\", \n    x_col='filename',\n    y_col='category',\n    target_size=IMAGE_SIZE,\n    class_mode='categorical'\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:46.115312Z","iopub.execute_input":"2025-05-28T07:41:46.115551Z","iopub.status.idle":"2025-05-28T07:41:46.123038Z","shell.execute_reply.started":"2025-05-28T07:41:46.115535Z","shell.execute_reply":"2025-05-28T07:41:46.122120Z"}},"outputs":[],"execution_count":null},{"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T07:41:46.123925Z","iopub.execute_input":"2025-05-28T07:41:46.124175Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"epochs=3 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":{"trusted":true,"execution":{"iopub.status.idle":"2025-05-28T08:15:26.036428Z","shell.execute_reply.started":"2025-05-28T07:41:48.153416Z","shell.execute_reply":"2025-05-28T08:15:26.035849Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.save_weights(\"model.weights.h5\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:26.037393Z","iopub.execute_input":"2025-05-28T08:15:26.037665Z","iopub.status.idle":"2025-05-28T08:15:26.448883Z","shell.execute_reply.started":"2025-05-28T08:15:26.037637Z","shell.execute_reply":"2025-05-28T08:15:26.448094Z"}},"outputs":[],"execution_count":null},{"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, 42, 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, 42, 1))\n\nlegend = plt.legend(loc='best', shadow=True)\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:23:47.731419Z","iopub.execute_input":"2025-05-28T08:23:47.731994Z","iopub.status.idle":"2025-05-28T08:23:48.288516Z","shell.execute_reply.started":"2025-05-28T08:23:47.731969Z","shell.execute_reply":"2025-05-28T08:23:48.287838Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_filenames = os.listdir(\"/kaggle/working/test1/test1/\")\ntest_df = pd.DataFrame({\n    'filename': test_filenames\n})\nnb_samples = test_df.shape[0]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:26.932917Z","iopub.execute_input":"2025-05-28T08:15:26.933143Z","iopub.status.idle":"2025-05-28T08:15:26.945685Z","shell.execute_reply.started":"2025-05-28T08:15:26.933124Z","shell.execute_reply":"2025-05-28T08:15:26.945117Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_gen = ImageDataGenerator(rescale=1./255)\ntest_generator = test_gen.flow_from_dataframe(\n    test_df, \n    \"/kaggle/working/test1/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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:26.946342Z","iopub.execute_input":"2025-05-28T08:15:26.946581Z","iopub.status.idle":"2025-05-28T08:15:27.031831Z","shell.execute_reply.started":"2025-05-28T08:15:26.946561Z","shell.execute_reply":"2025-05-28T08:15:27.031123Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"predict = model.predict(test_generator, steps=int(np.ceil(nb_samples/batch_size)))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:27.032615Z","iopub.execute_input":"2025-05-28T08:15:27.032833Z","iopub.status.idle":"2025-05-28T08:15:43.252204Z","shell.execute_reply.started":"2025-05-28T08:15:27.032787Z","shell.execute_reply":"2025-05-28T08:15:43.251628Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_df['category'] = np.argmax(predict, axis=-1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:43.256999Z","iopub.execute_input":"2025-05-28T08:15:43.257686Z","iopub.status.idle":"2025-05-28T08:15:43.262216Z","shell.execute_reply.started":"2025-05-28T08:15:43.257666Z","shell.execute_reply":"2025-05-28T08:15:43.261404Z"}},"outputs":[],"execution_count":null},{"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:43.263094Z","iopub.execute_input":"2025-05-28T08:15:43.263334Z","iopub.status.idle":"2025-05-28T08:15:43.279760Z","shell.execute_reply.started":"2025-05-28T08:15:43.263313Z","shell.execute_reply":"2025-05-28T08:15:43.279032Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_df['category'] = test_df['category'].replace({ 'dog': 1, 'cat': 0 })","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:43.280260Z","iopub.execute_input":"2025-05-28T08:15:43.280418Z","iopub.status.idle":"2025-05-28T08:15:43.300183Z","shell.execute_reply.started":"2025-05-28T08:15:43.280406Z","shell.execute_reply":"2025-05-28T08:15:43.299422Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_df['category'].value_counts().plot.bar()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:43.300887Z","iopub.execute_input":"2025-05-28T08:15:43.301136Z","iopub.status.idle":"2025-05-28T08:15:43.424226Z","shell.execute_reply.started":"2025-05-28T08:15:43.301117Z","shell.execute_reply":"2025-05-28T08:15:43.423439Z"}},"outputs":[],"execution_count":null},{"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(\"/kaggle/working/test1/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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:43.425033Z","iopub.execute_input":"2025-05-28T08:15:43.425282Z","iopub.status.idle":"2025-05-28T08:15:47.012706Z","shell.execute_reply.started":"2025-05-28T08:15:43.425266Z","shell.execute_reply":"2025-05-28T08:15:47.011558Z"}},"outputs":[],"execution_count":null},{"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-28T08:15:47.013685Z","iopub.execute_input":"2025-05-28T08:15:47.013935Z"}},"outputs":[],"execution_count":null}]}