{"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\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-10-24T10:04:19.546497Z","iopub.execute_input":"2023-10-24T10:04:19.546816Z","iopub.status.idle":"2023-10-24T10:04:20.109914Z","shell.execute_reply.started":"2023-10-24T10:04:19.54679Z","shell.execute_reply":"2023-10-24T10:04:20.108303Z"},"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-10-24T10:04:20.11265Z","iopub.execute_input":"2023-10-24T10:04:20.113292Z","iopub.status.idle":"2023-10-24T10:04:31.112298Z","shell.execute_reply.started":"2023-10-24T10:04:20.113253Z","shell.execute_reply":"2023-10-24T10:04:31.111234Z"},"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-10-24T10:04:31.11445Z","iopub.execute_input":"2023-10-24T10:04:31.115589Z","iopub.status.idle":"2023-10-24T10:04:31.16668Z","shell.execute_reply.started":"2023-10-24T10:04:31.115548Z","shell.execute_reply":"2023-10-24T10:04:31.165656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.nunique()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.168652Z","iopub.execute_input":"2023-10-24T10:04:31.16907Z","iopub.status.idle":"2023-10-24T10:04:31.188464Z","shell.execute_reply.started":"2023-10-24T10:04:31.169036Z","shell.execute_reply":"2023-10-24T10:04:31.187131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['label'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.191934Z","iopub.execute_input":"2023-10-24T10:04:31.192236Z","iopub.status.idle":"2023-10-24T10:04:31.203998Z","shell.execute_reply.started":"2023-10-24T10:04:31.192203Z","shell.execute_reply":"2023-10-24T10:04:31.202722Z"},"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-10-24T10:04:31.205512Z","iopub.execute_input":"2023-10-24T10:04:31.205775Z","iopub.status.idle":"2023-10-24T10:04:31.412652Z","shell.execute_reply.started":"2023-10-24T10:04:31.205752Z","shell.execute_reply":"2023-10-24T10:04:31.411016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.415614Z","iopub.execute_input":"2023-10-24T10:04:31.415959Z","iopub.status.idle":"2023-10-24T10:04:31.426683Z","shell.execute_reply.started":"2023-10-24T10:04:31.415932Z","shell.execute_reply":"2023-10-24T10:04:31.425625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.42779Z","iopub.execute_input":"2023-10-24T10:04:31.428096Z","iopub.status.idle":"2023-10-24T10:04:31.450621Z","shell.execute_reply.started":"2023-10-24T10:04:31.428072Z","shell.execute_reply":"2023-10-24T10:04:31.449659Z"},"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-10-24T10:04:31.452257Z","iopub.execute_input":"2023-10-24T10:04:31.452749Z","iopub.status.idle":"2023-10-24T10:04:31.609747Z","shell.execute_reply.started":"2023-10-24T10:04:31.452723Z","shell.execute_reply":"2023-10-24T10:04:31.609038Z"},"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-10-24T10:04:31.61073Z","iopub.execute_input":"2023-10-24T10:04:31.611241Z","iopub.status.idle":"2023-10-24T10:04:31.617435Z","shell.execute_reply.started":"2023-10-24T10:04:31.611214Z","shell.execute_reply":"2023-10-24T10:04:31.61673Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_folder[:5]","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.618507Z","iopub.execute_input":"2023-10-24T10:04:31.61896Z","iopub.status.idle":"2023-10-24T10:04:31.629026Z","shell.execute_reply.started":"2023-10-24T10:04:31.618934Z","shell.execute_reply":"2023-10-24T10:04:31.628278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_folder","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.630156Z","iopub.execute_input":"2023-10-24T10:04:31.630574Z","iopub.status.idle":"2023-10-24T10:04:31.640662Z","shell.execute_reply.started":"2023-10-24T10:04:31.630549Z","shell.execute_reply":"2023-10-24T10:04:31.639891Z"},"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-10-24T10:04:31.641785Z","iopub.execute_input":"2023-10-24T10:04:31.642278Z","iopub.status.idle":"2023-10-24T10:04:31.654239Z","shell.execute_reply.started":"2023-10-24T10:04:31.642248Z","shell.execute_reply":"2023-10-24T10:04:31.653278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.659571Z","iopub.execute_input":"2023-10-24T10:04:31.660376Z","iopub.status.idle":"2023-10-24T10:04:31.673352Z","shell.execute_reply.started":"2023-10-24T10:04:31.660349Z","shell.execute_reply":"2023-10-24T10:04:31.672241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.describe()","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:38:24.178118Z","iopub.execute_input":"2023-10-24T10:38:24.178507Z","iopub.status.idle":"2023-10-24T10:38:24.202526Z","shell.execute_reply.started":"2023-10-24T10:38:24.178476Z","shell.execute_reply":"2023-10-24T10:38:24.20118Z"},"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-10-24T10:04:31.675352Z","iopub.execute_input":"2023-10-24T10:04:31.676015Z","iopub.status.idle":"2023-10-24T10:04:31.69747Z","shell.execute_reply.started":"2023-10-24T10:04:31.675979Z","shell.execute_reply":"2023-10-24T10:04:31.69626Z"},"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-10-24T10:04:31.699632Z","iopub.execute_input":"2023-10-24T10:04:31.70017Z","iopub.status.idle":"2023-10-24T10:04:31.712958Z","shell.execute_reply.started":"2023-10-24T10:04:31.700138Z","shell.execute_reply":"2023-10-24T10:04:31.712282Z"},"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-10-24T10:04:31.713791Z","iopub.execute_input":"2023-10-24T10:04:31.714316Z","iopub.status.idle":"2023-10-24T10:04:31.719884Z","shell.execute_reply.started":"2023-10-24T10:04:31.714292Z","shell.execute_reply":"2023-10-24T10:04:31.719179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_no_tma","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.721023Z","iopub.execute_input":"2023-10-24T10:04:31.722462Z","iopub.status.idle":"2023-10-24T10:04:31.742408Z","shell.execute_reply.started":"2023-10-24T10:04:31.722414Z","shell.execute_reply":"2023-10-24T10:04:31.741225Z"},"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-10-24T10:04:31.743974Z","iopub.execute_input":"2023-10-24T10:04:31.744697Z","iopub.status.idle":"2023-10-24T10:04:31.757724Z","shell.execute_reply.started":"2023-10-24T10:04:31.74462Z","shell.execute_reply":"2023-10-24T10:04:31.756983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_tma","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.758887Z","iopub.execute_input":"2023-10-24T10:04:31.759153Z","iopub.status.idle":"2023-10-24T10:04:31.777243Z","shell.execute_reply.started":"2023-10-24T10:04:31.759129Z","shell.execute_reply":"2023-10-24T10:04:31.775653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## Train Images data Preprocessing","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.778592Z","iopub.execute_input":"2023-10-24T10:04:31.77941Z","iopub.status.idle":"2023-10-24T10:04:31.788144Z","shell.execute_reply.started":"2023-10-24T10:04:31.779374Z","shell.execute_reply":"2023-10-24T10:04:31.787164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_folder[:5] ","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:04:31.78936Z","iopub.execute_input":"2023-10-24T10:04:31.790125Z","iopub.status.idle":"2023-10-24T10:04:31.807791Z","shell.execute_reply.started":"2023-10-24T10:04:31.790057Z","shell.execute_reply":"2023-10-24T10:04:31.806482Z"},"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-10-24T10:04:31.809426Z","iopub.execute_input":"2023-10-24T10:04:31.809842Z","iopub.status.idle":"2023-10-24T10:05:04.649488Z","shell.execute_reply.started":"2023-10-24T10:04:31.809818Z","shell.execute_reply":"2023-10-24T10:05:04.648629Z"},"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-10-24T10:05:04.650652Z","iopub.execute_input":"2023-10-24T10:05:04.651457Z","iopub.status.idle":"2023-10-24T10:05:04.657472Z","shell.execute_reply.started":"2023-10-24T10:05:04.651431Z","shell.execute_reply":"2023-10-24T10:05:04.656812Z"},"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-10-24T10:05:04.65871Z","iopub.execute_input":"2023-10-24T10:05:04.659502Z","iopub.status.idle":"2023-10-24T10:07:25.798573Z","shell.execute_reply.started":"2023-10-24T10:05:04.65945Z","shell.execute_reply":"2023-10-24T10:07:25.797432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(image_data))\nprint(len(image_label))","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:07:25.800146Z","iopub.execute_input":"2023-10-24T10:07:25.800428Z","iopub.status.idle":"2023-10-24T10:07:25.805631Z","shell.execute_reply.started":"2023-10-24T10:07:25.800403Z","shell.execute_reply":"2023-10-24T10:07:25.804525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"set(image_label)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:07:25.8069Z","iopub.execute_input":"2023-10-24T10:07:25.807197Z","iopub.status.idle":"2023-10-24T10:07:25.823775Z","shell.execute_reply.started":"2023-10-24T10:07:25.80717Z","shell.execute_reply":"2023-10-24T10:07:25.82279Z"},"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-10-24T10:07:25.825956Z","iopub.execute_input":"2023-10-24T10:07:25.8265Z","iopub.status.idle":"2023-10-24T10:07:25.840113Z","shell.execute_reply.started":"2023-10-24T10:07:25.826467Z","shell.execute_reply":"2023-10-24T10:07:25.838179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(image_label_1)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:07:25.841703Z","iopub.execute_input":"2023-10-24T10:07:25.842315Z","iopub.status.idle":"2023-10-24T10:07:25.855648Z","shell.execute_reply.started":"2023-10-24T10:07:25.842277Z","shell.execute_reply":"2023-10-24T10:07:25.854004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_label_1[:5]","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:07:25.856986Z","iopub.execute_input":"2023-10-24T10:07:25.857386Z","iopub.status.idle":"2023-10-24T10:07:25.869427Z","shell.execute_reply.started":"2023-10-24T10:07:25.857357Z","shell.execute_reply":"2023-10-24T10:07:25.867723Z"},"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-10-24T10:07:25.871239Z","iopub.execute_input":"2023-10-24T10:07:25.871554Z","iopub.status.idle":"2023-10-24T10:07:25.89745Z","shell.execute_reply.started":"2023-10-24T10:07:25.871525Z","shell.execute_reply":"2023-10-24T10:07:25.895957Z"},"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-10-24T10:07:25.898911Z","iopub.execute_input":"2023-10-24T10:07:25.899249Z","iopub.status.idle":"2023-10-24T10:07:25.921561Z","shell.execute_reply.started":"2023-10-24T10:07:25.89922Z","shell.execute_reply":"2023-10-24T10:07:25.920664Z"},"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-10-24T10:07:25.923413Z","iopub.execute_input":"2023-10-24T10:07:25.924034Z","iopub.status.idle":"2023-10-24T10:07:28.699604Z","shell.execute_reply.started":"2023-10-24T10:07:25.924002Z","shell.execute_reply":"2023-10-24T10:07:28.697788Z"},"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-10-24T10:07:28.701405Z","iopub.execute_input":"2023-10-24T10:07:28.701694Z","iopub.status.idle":"2023-10-24T10:07:28.81983Z","shell.execute_reply.started":"2023-10-24T10:07:28.701668Z","shell.execute_reply":"2023-10-24T10:07:28.818664Z"},"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-10-24T10:07:28.820951Z","iopub.execute_input":"2023-10-24T10:07:28.821267Z","iopub.status.idle":"2023-10-24T10:07:29.198077Z","shell.execute_reply.started":"2023-10-24T10:07:28.821243Z","shell.execute_reply":"2023-10-24T10:07:29.196894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(x_train_scaled,y_train,epochs=15,\n         batch_size=64,validation_data=(x_test_scaled,y_test))","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:07:29.199378Z","iopub.execute_input":"2023-10-24T10:07:29.199767Z","iopub.status.idle":"2023-10-24T10:07:29.205911Z","shell.execute_reply.started":"2023-10-24T10:07:29.199733Z","shell.execute_reply":"2023-10-24T10:07:29.204118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\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 = '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)","metadata":{"execution":{"iopub.status.busy":"2023-10-24T10:31:03.136785Z","iopub.execute_input":"2023-10-24T10:31:03.13726Z","iopub.status.idle":"2023-10-24T10:31:03.152373Z","shell.execute_reply.started":"2023-10-24T10:31:03.137224Z","shell.execute_reply":"2023-10-24T10:31:03.151273Z"},"trusted":true},"execution_count":null,"outputs":[]}]}