{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":45867,"databundleVersionId":6924515,"sourceType":"competition"},{"sourceId":6774400,"sourceType":"datasetVersion","datasetId":3895136},{"sourceId":6774553,"sourceType":"datasetVersion","datasetId":3898019},{"sourceId":151484971,"sourceType":"kernelVersion"}],"dockerImageVersionId":30559,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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\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        break","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-11-25T19:28:09.184023Z","iopub.execute_input":"2023-11-25T19:28:09.184406Z","iopub.status.idle":"2023-11-25T19:28:09.219817Z","shell.execute_reply.started":"2023-11-25T19:28:09.184377Z","shell.execute_reply":"2023-11-25T19:28:09.218887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings('ignore')\n\nimport os\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport seaborn as sns\nfrom sklearn.metrics import classification_report , confusion_matrix , accuracy_score , auc\nfrom sklearn.model_selection import train_test_split\n\nimport cv2\n#from google.colab.patches import cv2_imshow\nfrom PIL import Image \nimport tensorflow as tf\nfrom tensorflow import keras\nfrom keras import Sequential\nfrom keras.layers import Input, Dense,Conv2D , MaxPooling2D, Flatten,BatchNormalization,Dropout\nfrom tensorflow.keras.preprocessing import image_dataset_from_directory\nimport tensorflow_hub as hub ","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.222057Z","iopub.execute_input":"2023-11-25T19:28:09.222426Z","iopub.status.idle":"2023-11-25T19:28:09.231458Z","shell.execute_reply.started":"2023-11-25T19:28:09.222393Z","shell.execute_reply":"2023-11-25T19:28:09.230532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv(\"/kaggle/input/UBC-OCEAN/train.csv\")\ntrain_df","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.232458Z","iopub.execute_input":"2023-11-25T19:28:09.232731Z","iopub.status.idle":"2023-11-25T19:28:09.257313Z","shell.execute_reply.started":"2023-11-25T19:28:09.232698Z","shell.execute_reply":"2023-11-25T19:28:09.256561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.nunique()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.258264Z","iopub.execute_input":"2023-11-25T19:28:09.258529Z","iopub.status.idle":"2023-11-25T19:28:09.266363Z","shell.execute_reply.started":"2023-11-25T19:28:09.258505Z","shell.execute_reply":"2023-11-25T19:28:09.26546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['label'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.269619Z","iopub.execute_input":"2023-11-25T19:28:09.270161Z","iopub.status.idle":"2023-11-25T19:28:09.277186Z","shell.execute_reply.started":"2023-11-25T19:28:09.270137Z","shell.execute_reply":"2023-11-25T19:28:09.276316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data=train_df, x=\"label\")\nplt.title(\"Ovarian Cancer Types Distributions\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.278245Z","iopub.execute_input":"2023-11-25T19:28:09.278509Z","iopub.status.idle":"2023-11-25T19:28:09.457397Z","shell.execute_reply.started":"2023-11-25T19:28:09.278486Z","shell.execute_reply":"2023-11-25T19:28:09.456443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.45888Z","iopub.execute_input":"2023-11-25T19:28:09.459221Z","iopub.status.idle":"2023-11-25T19:28:09.469634Z","shell.execute_reply.started":"2023-11-25T19:28:09.459188Z","shell.execute_reply":"2023-11-25T19:28:09.468707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.471312Z","iopub.execute_input":"2023-11-25T19:28:09.47172Z","iopub.status.idle":"2023-11-25T19:28:09.48298Z","shell.execute_reply.started":"2023-11-25T19:28:09.471686Z","shell.execute_reply":"2023-11-25T19:28:09.482142Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.subplot(1,2,1)\ntrain_df[['image_width']].boxplot()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.484221Z","iopub.execute_input":"2023-11-25T19:28:09.484557Z","iopub.status.idle":"2023-11-25T19:28:09.623618Z","shell.execute_reply.started":"2023-11-25T19:28:09.484525Z","shell.execute_reply":"2023-11-25T19:28:09.622664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path_train = \"/kaggle/input/UBC-OCEAN/train_images\"\npath_test = \"/kaggle/input/UBC-OCEAN/test_images\"\ntrain_folder = os.listdir(path_train)\ntest_folder = os.listdir(path_test)\n\nprint(len(train_folder))\nprint(len(test_folder))","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.625165Z","iopub.execute_input":"2023-11-25T19:28:09.62576Z","iopub.status.idle":"2023-11-25T19:28:09.633541Z","shell.execute_reply.started":"2023-11-25T19:28:09.625725Z","shell.execute_reply":"2023-11-25T19:28:09.63252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_folder[:5]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.635252Z","iopub.execute_input":"2023-11-25T19:28:09.635599Z","iopub.status.idle":"2023-11-25T19:28:09.643824Z","shell.execute_reply.started":"2023-11-25T19:28:09.635568Z","shell.execute_reply":"2023-11-25T19:28:09.642885Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_folder","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.645089Z","iopub.execute_input":"2023-11-25T19:28:09.64564Z","iopub.status.idle":"2023-11-25T19:28:09.655298Z","shell.execute_reply.started":"2023-11-25T19:28:09.645602Z","shell.execute_reply":"2023-11-25T19:28:09.654313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## Images in small size\npath_train_copy = \"/kaggle/input/UBC-OCEAN/train_thumbnails\"\npath_test_copy = \"/kaggle/input/UBC-OCEAN/test_thumbnails\"\ntrain_folder_copy = os.listdir(path_train_copy)\ntest_folder_copy = os.listdir(path_test_copy)\n\nprint(len(train_folder_copy))\nprint(len(test_folder_copy))","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.656589Z","iopub.execute_input":"2023-11-25T19:28:09.657467Z","iopub.status.idle":"2023-11-25T19:28:09.665464Z","shell.execute_reply.started":"2023-11-25T19:28:09.657435Z","shell.execute_reply":"2023-11-25T19:28:09.664823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.670813Z","iopub.execute_input":"2023-11-25T19:28:09.671351Z","iopub.status.idle":"2023-11-25T19:28:09.683935Z","shell.execute_reply.started":"2023-11-25T19:28:09.671319Z","shell.execute_reply":"2023-11-25T19:28:09.683156Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.describe()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.6848Z","iopub.execute_input":"2023-11-25T19:28:09.685073Z","iopub.status.idle":"2023-11-25T19:28:09.702704Z","shell.execute_reply.started":"2023-11-25T19:28:09.68505Z","shell.execute_reply":"2023-11-25T19:28:09.701888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## Image id >> Tissue Microarray\ntrain_df_tma = train_df[train_df['is_tma']==True]\ntrain_df_tma","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.703713Z","iopub.execute_input":"2023-11-25T19:28:09.703973Z","iopub.status.idle":"2023-11-25T19:28:09.717265Z","shell.execute_reply.started":"2023-11-25T19:28:09.70395Z","shell.execute_reply":"2023-11-25T19:28:09.716454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_no_tma = train_df[train_df['is_tma']==False]\ntrain_df_no_tma","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.718513Z","iopub.execute_input":"2023-11-25T19:28:09.718776Z","iopub.status.idle":"2023-11-25T19:28:09.735222Z","shell.execute_reply.started":"2023-11-25T19:28:09.718753Z","shell.execute_reply":"2023-11-25T19:28:09.73429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_no_tma['image_id_path'] = [f\"{i}_thumbnail.png\" for i in train_df_no_tma['image_id']]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.736218Z","iopub.execute_input":"2023-11-25T19:28:09.736516Z","iopub.status.idle":"2023-11-25T19:28:09.744585Z","shell.execute_reply.started":"2023-11-25T19:28:09.736492Z","shell.execute_reply":"2023-11-25T19:28:09.743594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_no_tma","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.745701Z","iopub.execute_input":"2023-11-25T19:28:09.745974Z","iopub.status.idle":"2023-11-25T19:28:09.765773Z","shell.execute_reply.started":"2023-11-25T19:28:09.74595Z","shell.execute_reply":"2023-11-25T19:28:09.764865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_tma['image_id_path'] = [f\"{i}.png\" for i in train_df_tma['image_id']]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.766999Z","iopub.execute_input":"2023-11-25T19:28:09.767364Z","iopub.status.idle":"2023-11-25T19:28:09.776638Z","shell.execute_reply.started":"2023-11-25T19:28:09.767325Z","shell.execute_reply":"2023-11-25T19:28:09.773073Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_tma","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.778116Z","iopub.execute_input":"2023-11-25T19:28:09.778473Z","iopub.status.idle":"2023-11-25T19:28:09.793227Z","shell.execute_reply.started":"2023-11-25T19:28:09.778439Z","shell.execute_reply":"2023-11-25T19:28:09.792268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## Train Images data Preprocessing","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.794152Z","iopub.execute_input":"2023-11-25T19:28:09.794386Z","iopub.status.idle":"2023-11-25T19:28:09.804398Z","shell.execute_reply.started":"2023-11-25T19:28:09.794365Z","shell.execute_reply":"2023-11-25T19:28:09.803473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_folder[:5] ","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.805501Z","iopub.execute_input":"2023-11-25T19:28:09.805852Z","iopub.status.idle":"2023-11-25T19:28:09.815Z","shell.execute_reply.started":"2023-11-25T19:28:09.805806Z","shell.execute_reply":"2023-11-25T19:28:09.814111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,24))\npath = \"/kaggle/input/UBC-OCEAN/train_thumbnails\"\nj=1\nfor img, lb in zip(train_df_no_tma['image_id_path'][:24],train_df_no_tma['label'][:24]):\n    plt.subplot(6,4,j)\n    path = os.path.join(\"/kaggle/input/UBC-OCEAN/train_thumbnails/\",img)\n    image = plt.imread(path)\n    image = plt.imshow(image)\n    plt.title(f\"Label:{lb}\")\n    j+=1","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:09.816183Z","iopub.execute_input":"2023-11-25T19:28:09.816589Z","iopub.status.idle":"2023-11-25T19:28:51.92571Z","shell.execute_reply.started":"2023-11-25T19:28:09.816557Z","shell.execute_reply":"2023-11-25T19:28:51.924777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_df['image_width'].min())\nprint(train_df['image_width'].max())\nprint(train_df['image_width'].mean())\nprint()\nprint(train_df['image_height'].min())\nprint(train_df['image_height'].max())\nprint(train_df['image_height'].mean())","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:51.926942Z","iopub.execute_input":"2023-11-25T19:28:51.927232Z","iopub.status.idle":"2023-11-25T19:28:51.93464Z","shell.execute_reply.started":"2023-11-25T19:28:51.927206Z","shell.execute_reply":"2023-11-25T19:28:51.933785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_data = []\nimage_label = []\npath = \"/kaggle/input/UBC-OCEAN/train_thumbnails\"\npath1=\"/kaggle/input/UBC-OCEAN/train_images/\"\nfor img , label in zip(train_df_no_tma['image_id_path'],train_df_no_tma['label']):\n    image = Image.open(\"/kaggle/input/UBC-OCEAN/train_thumbnails/\"+img)\n    image = image.resize((224,224))\n    image = image.convert(\"RGB\")\n    image = np.array(image)\n    image_data.append(image)\n    image_label.append(label)\n\nfor img , label in zip(train_df_tma['image_id_path'],train_df_tma['label']):\n    image = Image.open(\"/kaggle/input/UBC-OCEAN/train_images/\"+img)\n    image = image.resize((224,224))\n    image = image.convert(\"RGB\")\n    image = np.array(image)\n    image_data.append(image)\n    image_label.append(label)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:28:51.935883Z","iopub.execute_input":"2023-11-25T19:28:51.936205Z","iopub.status.idle":"2023-11-25T19:30:54.035846Z","shell.execute_reply.started":"2023-11-25T19:28:51.936177Z","shell.execute_reply":"2023-11-25T19:30:54.034894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(image_data))\nprint(len(image_label))","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.037243Z","iopub.execute_input":"2023-11-25T19:30:54.037617Z","iopub.status.idle":"2023-11-25T19:30:54.043347Z","shell.execute_reply.started":"2023-11-25T19:30:54.037574Z","shell.execute_reply":"2023-11-25T19:30:54.042404Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"set(image_label)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.044604Z","iopub.execute_input":"2023-11-25T19:30:54.045446Z","iopub.status.idle":"2023-11-25T19:30:54.055531Z","shell.execute_reply.started":"2023-11-25T19:30:54.045412Z","shell.execute_reply":"2023-11-25T19:30:54.054492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_label_1 = []\nfor i in image_label:\n    if i==\"CC\":\n        image_label_1.append(0)\n    elif i==\"EC\":\n        image_label_1.append(1)\n    elif i==\"HGSC\":\n        image_label_1.append(2)\n    elif i==\"LGSC\":\n        image_label_1.append(3)\n    elif i==\"MC\":\n        image_label_1.append(4)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.05682Z","iopub.execute_input":"2023-11-25T19:30:54.05725Z","iopub.status.idle":"2023-11-25T19:30:54.06497Z","shell.execute_reply.started":"2023-11-25T19:30:54.057219Z","shell.execute_reply":"2023-11-25T19:30:54.064131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(image_label_1)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.066152Z","iopub.execute_input":"2023-11-25T19:30:54.066545Z","iopub.status.idle":"2023-11-25T19:30:54.077301Z","shell.execute_reply.started":"2023-11-25T19:30:54.066516Z","shell.execute_reply":"2023-11-25T19:30:54.076426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_label_1[:5]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.078686Z","iopub.execute_input":"2023-11-25T19:30:54.079078Z","iopub.status.idle":"2023-11-25T19:30:54.09023Z","shell.execute_reply.started":"2023-11-25T19:30:54.079047Z","shell.execute_reply":"2023-11-25T19:30:54.089352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = np.array(image_data)\ny = np.array(image_label_1)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.093215Z","iopub.execute_input":"2023-11-25T19:30:54.093535Z","iopub.status.idle":"2023-11-25T19:30:54.127914Z","shell.execute_reply.started":"2023-11-25T19:30:54.093506Z","shell.execute_reply":"2023-11-25T19:30:54.126891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train , x_test, y_train, y_test = train_test_split(x,y,test_size=0.15,shuffle=True)\nprint(x_train.shape)\nprint(x_test.shape)\nprint(y_train.shape)\nprint(y_test.shape)\n(457, 224, 224, 3)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.129205Z","iopub.execute_input":"2023-11-25T19:30:54.129492Z","iopub.status.idle":"2023-11-25T19:30:54.163387Z","shell.execute_reply.started":"2023-11-25T19:30:54.129467Z","shell.execute_reply":"2023-11-25T19:30:54.16253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,16))\nclass_labels = ['CC', 'EC', 'HGSC', 'LGSC', 'MC']\nfor i in range(12):\n    plt.subplot(4,3,i+1)\n    plt.imshow(x_train[i])\n    plt.title(f\"Label:{class_labels[y_train[i]]}\")","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:54.164766Z","iopub.execute_input":"2023-11-25T19:30:54.165142Z","iopub.status.idle":"2023-11-25T19:30:57.106293Z","shell.execute_reply.started":"2023-11-25T19:30:54.165109Z","shell.execute_reply":"2023-11-25T19:30:57.105354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_scaled = x_train/255\nx_test_scaled = x_test/255","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:57.107445Z","iopub.execute_input":"2023-11-25T19:30:57.107746Z","iopub.status.idle":"2023-11-25T19:30:57.314302Z","shell.execute_reply.started":"2023-11-25T19:30:57.10772Z","shell.execute_reply":"2023-11-25T19:30:57.313217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = Sequential()\nmodel.add(Conv2D(filters=120,kernel_size=(3,3),strides=(1,1),activation='relu',input_shape=(224,224,3)))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(filters=100,kernel_size=(3,3),strides=(1,1),activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(filters=80,kernel_size=(3,3),strides=(1,1),activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(filters=64,kernel_size=(3,3),strides=(1,1),activation='relu',input_shape=(224,224,3)))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Flatten())\nmodel.add(Dense(units=600,activation='relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(units=600,activation='relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(units=5,activation='softmax'))\n\nmodel.compile(optimizer=\"adam\",loss=\"sparse_categorical_crossentropy\",\n             metrics=[\"accuracy\"])\n\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:57.315705Z","iopub.execute_input":"2023-11-25T19:30:57.316037Z","iopub.status.idle":"2023-11-25T19:30:57.46125Z","shell.execute_reply.started":"2023-11-25T19:30:57.316011Z","shell.execute_reply":"2023-11-25T19:30:57.460358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(x_train_scaled,y_train,epochs=1,\n         batch_size=1,validation_data=(x_test_scaled,y_test))","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:30:57.462488Z","iopub.execute_input":"2023-11-25T19:30:57.46286Z","iopub.status.idle":"2023-11-25T19:31:03.243521Z","shell.execute_reply.started":"2023-11-25T19:30:57.462811Z","shell.execute_reply":"2023-11-25T19:31:03.242673Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport os  # Importing the os module\n\n# Load the CSV file into a DataFrame\ntrain_df_tma = pd.read_csv(\"/kaggle/input/UBC-OCEAN/train.csv\")\n\n# Specify the file path where you want to write the selected columns\noutput_file = '/kaggle/working/submission.csv'\n\n# Select the desired columns\nselected_columns = train_df_tma[['image_id', 'label']]\n\n# Write the selected columns to a CSV file\nselected_columns.to_csv(output_file, index=False)\n\n# Check if the file has been created in the specified directory\nwhile \"submission.csv\" not in os.listdir(\"/kaggle/working\"):\n    selected_columns.to_csv(output_file, index=False)\n","metadata":{"execution":{"iopub.status.busy":"2023-11-25T19:31:03.24488Z","iopub.execute_input":"2023-11-25T19:31:03.245215Z","iopub.status.idle":"2023-11-25T19:31:03.257774Z","shell.execute_reply.started":"2023-11-25T19:31:03.245187Z","shell.execute_reply":"2023-11-25T19:31:03.256973Z"},"trusted":true},"execution_count":null,"outputs":[]}]}