{"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":"nvidiaTeslaT4","dataSources":[{"sourceId":45867,"databundleVersionId":6924515,"sourceType":"competition"},{"sourceId":830,"sourceType":"modelInstanceVersion","modelInstanceId":695}],"dockerImageVersionId":30627,"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","execution":{"iopub.status.busy":"2023-12-16T09:18:47.342868Z","iopub.execute_input":"2023-12-16T09:18:47.343286Z","iopub.status.idle":"2023-12-16T09:18:47.889166Z","shell.execute_reply.started":"2023-12-16T09:18:47.343248Z","shell.execute_reply":"2023-12-16T09:18:47.88802Z"},"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\n\nimport cv2\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-12-16T09:19:54.503153Z","iopub.execute_input":"2023-12-16T09:19:54.503684Z","iopub.status.idle":"2023-12-16T09:20:08.368389Z","shell.execute_reply.started":"2023-12-16T09:19:54.503653Z","shell.execute_reply":"2023-12-16T09:20:08.367543Z"},"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-12-16T09:20:26.794728Z","iopub.execute_input":"2023-12-16T09:20:26.795722Z","iopub.status.idle":"2023-12-16T09:20:26.829033Z","shell.execute_reply.started":"2023-12-16T09:20:26.795689Z","shell.execute_reply":"2023-12-16T09:20:26.828105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.nunique()","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:20:41.520666Z","iopub.execute_input":"2023-12-16T09:20:41.521316Z","iopub.status.idle":"2023-12-16T09:20:41.53782Z","shell.execute_reply.started":"2023-12-16T09:20:41.52128Z","shell.execute_reply":"2023-12-16T09:20:41.536746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.describe()","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:20:57.129581Z","iopub.execute_input":"2023-12-16T09:20:57.129933Z","iopub.status.idle":"2023-12-16T09:20:57.152835Z","shell.execute_reply.started":"2023-12-16T09:20:57.129905Z","shell.execute_reply":"2023-12-16T09:20:57.151644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['label'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:21:19.491204Z","iopub.execute_input":"2023-12-16T09:21:19.491613Z","iopub.status.idle":"2023-12-16T09:21:19.503045Z","shell.execute_reply.started":"2023-12-16T09:21:19.491582Z","shell.execute_reply":"2023-12-16T09:21:19.502035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data=train_df, x=\"label\")\nplt.title(\"Ovarian Cancer Types!\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:21:51.286829Z","iopub.execute_input":"2023-12-16T09:21:51.287463Z","iopub.status.idle":"2023-12-16T09:21:51.559077Z","shell.execute_reply.started":"2023-12-16T09:21:51.287429Z","shell.execute_reply":"2023-12-16T09:21:51.558057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:22:25.787523Z","iopub.execute_input":"2023-12-16T09:22:25.788539Z","iopub.status.idle":"2023-12-16T09:22:25.802457Z","shell.execute_reply.started":"2023-12-16T09:22:25.788484Z","shell.execute_reply":"2023-12-16T09:22:25.801422Z"},"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-12-16T09:22:53.63544Z","iopub.execute_input":"2023-12-16T09:22:53.636144Z","iopub.status.idle":"2023-12-16T09:22:53.642822Z","shell.execute_reply.started":"2023-12-16T09:22:53.636112Z","shell.execute_reply":"2023-12-16T09:22:53.641849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Small Size Images..\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-12-16T09:23:17.067825Z","iopub.execute_input":"2023-12-16T09:23:17.068183Z","iopub.status.idle":"2023-12-16T09:23:17.075917Z","shell.execute_reply.started":"2023-12-16T09:23:17.068155Z","shell.execute_reply":"2023-12-16T09:23:17.074945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:24:07.868329Z","iopub.execute_input":"2023-12-16T09:24:07.869183Z","iopub.status.idle":"2023-12-16T09:24:07.882673Z","shell.execute_reply.started":"2023-12-16T09:24:07.869148Z","shell.execute_reply":"2023-12-16T09:24:07.881845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df_tma = train_df[train_df['is_tma']==True]\ntrain_df_tma","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:24:43.12012Z","iopub.execute_input":"2023-12-16T09:24:43.120681Z","iopub.status.idle":"2023-12-16T09:24:43.135442Z","shell.execute_reply.started":"2023-12-16T09:24:43.12065Z","shell.execute_reply":"2023-12-16T09:24:43.13443Z"},"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-12-16T09:24:59.683925Z","iopub.execute_input":"2023-12-16T09:24:59.684285Z","iopub.status.idle":"2023-12-16T09:24:59.700001Z","shell.execute_reply.started":"2023-12-16T09:24:59.684254Z","shell.execute_reply":"2023-12-16T09:24:59.699074Z"},"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-12-16T09:25:17.882892Z","iopub.execute_input":"2023-12-16T09:25:17.883844Z","iopub.status.idle":"2023-12-16T09:25:17.892128Z","shell.execute_reply.started":"2023-12-16T09:25:17.883781Z","shell.execute_reply":"2023-12-16T09:25:17.890722Z"},"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-12-16T09:25:32.390026Z","iopub.execute_input":"2023-12-16T09:25:32.390396Z","iopub.status.idle":"2023-12-16T09:25:32.396257Z","shell.execute_reply.started":"2023-12-16T09:25:32.390368Z","shell.execute_reply":"2023-12-16T09:25:32.395188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_thumbnails_folder = train_folder_copy\ntrain_thumbnails_folder[:5]","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:26:02.173408Z","iopub.execute_input":"2023-12-16T09:26:02.174275Z","iopub.status.idle":"2023-12-16T09:26:02.179822Z","shell.execute_reply.started":"2023-12-16T09:26:02.174245Z","shell.execute_reply":"2023-12-16T09:26:02.178813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:26:19.159147Z","iopub.execute_input":"2023-12-16T09:26:19.159515Z","iopub.status.idle":"2023-12-16T09:26:19.169476Z","shell.execute_reply.started":"2023-12-16T09:26:19.159467Z","shell.execute_reply":"2023-12-16T09:26:19.168548Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Images from the thumbnail folder\n**","metadata":{}},{"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-12-16T09:27:30.445773Z","iopub.execute_input":"2023-12-16T09:27:30.446425Z","iopub.status.idle":"2023-12-16T09:28:16.219572Z","shell.execute_reply.started":"2023-12-16T09:27:30.446395Z","shell.execute_reply":"2023-12-16T09:28:16.21821Z"},"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/\"","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:28:55.167401Z","iopub.execute_input":"2023-12-16T09:28:55.167768Z","iopub.status.idle":"2023-12-16T09:28:55.172189Z","shell.execute_reply.started":"2023-12-16T09:28:55.16774Z","shell.execute_reply":"2023-12-16T09:28:55.171179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for 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((600,600))\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-12-16T09:29:11.562785Z","iopub.execute_input":"2023-12-16T09:29:11.563469Z","iopub.status.idle":"2023-12-16T09:31:33.618326Z","shell.execute_reply.started":"2023-12-16T09:29:11.563433Z","shell.execute_reply":"2023-12-16T09:31:33.617519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for 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((600,600))\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-12-16T09:31:59.815359Z","iopub.execute_input":"2023-12-16T09:31:59.815723Z","iopub.status.idle":"2023-12-16T09:32:15.194339Z","shell.execute_reply.started":"2023-12-16T09:31:59.815695Z","shell.execute_reply":"2023-12-16T09:32:15.193546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(image_data))\nprint(len(image_label))","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:32:33.47547Z","iopub.execute_input":"2023-12-16T09:32:33.47608Z","iopub.status.idle":"2023-12-16T09:32:33.480794Z","shell.execute_reply.started":"2023-12-16T09:32:33.476048Z","shell.execute_reply":"2023-12-16T09:32:33.479866Z"},"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-12-16T09:32:50.324093Z","iopub.execute_input":"2023-12-16T09:32:50.324853Z","iopub.status.idle":"2023-12-16T09:32:50.330701Z","shell.execute_reply.started":"2023-12-16T09:32:50.324813Z","shell.execute_reply":"2023-12-16T09:32:50.32955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(image_label_1)","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:33:06.427514Z","iopub.execute_input":"2023-12-16T09:33:06.428376Z","iopub.status.idle":"2023-12-16T09:33:06.434452Z","shell.execute_reply.started":"2023-12-16T09:33:06.428343Z","shell.execute_reply":"2023-12-16T09:33:06.433324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image_data = []\npath = \"/kaggle/input/UBC-OCEAN/test_thumbnails\"","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:33:34.922439Z","iopub.execute_input":"2023-12-16T09:33:34.922806Z","iopub.status.idle":"2023-12-16T09:33:34.927403Z","shell.execute_reply.started":"2023-12-16T09:33:34.922779Z","shell.execute_reply":"2023-12-16T09:33:34.926245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_thumbnail_folder = os.listdir(path)\n\nfor img in test_thumbnail_folder:\n    image = Image.open(\"/kaggle/input/UBC-OCEAN/test_thumbnails/\"+img)\n    image = image.resize((600,600))\n    image = image.convert(\"RGB\")\n    image = np.array(image)\n    test_image_data.append(image)","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:33:50.028154Z","iopub.execute_input":"2023-12-16T09:33:50.028507Z","iopub.status.idle":"2023-12-16T09:33:50.359678Z","shell.execute_reply.started":"2023-12-16T09:33:50.028464Z","shell.execute_reply":"2023-12-16T09:33:50.358859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image_data[0].shape","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:34:04.977312Z","iopub.execute_input":"2023-12-16T09:34:04.977664Z","iopub.status.idle":"2023-12-16T09:34:04.9839Z","shell.execute_reply.started":"2023-12-16T09:34:04.977626Z","shell.execute_reply":"2023-12-16T09:34:04.982803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predict_test_array = np.array(test_image_data)\n\n\n## Scaling  The test Images\npredict_test_array_scaled = predict_test_array/255","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:34:58.687148Z","iopub.execute_input":"2023-12-16T09:34:58.687996Z","iopub.status.idle":"2023-12-16T09:34:58.694169Z","shell.execute_reply.started":"2023-12-16T09:34:58.687963Z","shell.execute_reply":"2023-12-16T09:34:58.69304Z"},"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-12-16T09:35:02.339538Z","iopub.execute_input":"2023-12-16T09:35:02.34022Z","iopub.status.idle":"2023-12-16T09:35:02.514803Z","shell.execute_reply.started":"2023-12-16T09:35:02.340191Z","shell.execute_reply":"2023-12-16T09:35:02.513856Z"},"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.10,shuffle=True)\nprint(x_train.shape)\nprint(x_test.shape)\nprint(y_train.shape)\nprint(y_test.shape)","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:35:34.2368Z","iopub.execute_input":"2023-12-16T09:35:34.237144Z","iopub.status.idle":"2023-12-16T09:35:34.407286Z","shell.execute_reply.started":"2023-12-16T09:35:34.23712Z","shell.execute_reply":"2023-12-16T09:35:34.406308Z"},"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-12-16T09:36:25.283996Z","iopub.execute_input":"2023-12-16T09:36:25.284347Z","iopub.status.idle":"2023-12-16T09:36:26.784487Z","shell.execute_reply.started":"2023-12-16T09:36:25.284319Z","shell.execute_reply":"2023-12-16T09:36:26.783434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"*Transfer learning\n*","metadata":{}},{"cell_type":"code","source":"eff_path = \"/kaggle/input/efficientnet/tensorflow1/b7-classification/1\"\npath1 = \"/kaggle/input/efficientnet/tensorflow1/b7-classification/1\"\n","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:47:55.113272Z","iopub.execute_input":"2023-12-16T09:47:55.113641Z","iopub.status.idle":"2023-12-16T09:47:55.118143Z","shell.execute_reply.started":"2023-12-16T09:47:55.113613Z","shell.execute_reply":"2023-12-16T09:47:55.117161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"eff_model = hub.KerasLayer(path1,  input_shape=(600,600,3), trainable=False)\n\nnum_class = 5\nefficientnet_model = Sequential()\n\nefficientnet_model.add(eff_model)\nefficientnet_model.add(Dense(units=600, activation=\"relu\"))\nefficientnet_model.add(Dropout(0.2))\nefficientnet_model.add(Dense(units=600, activation=\"relu\"))\nefficientnet_model.add(Dropout(0.2))\nefficientnet_model.add(Dense(units=num_class, activation=\"softmax\"))\n\nefficientnet_model.summary()","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:47:58.582289Z","iopub.execute_input":"2023-12-16T09:47:58.58298Z","iopub.status.idle":"2023-12-16T09:48:20.036321Z","shell.execute_reply.started":"2023-12-16T09:47:58.582946Z","shell.execute_reply":"2023-12-16T09:48:20.03542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"efficientnet_model.compile(optimizer=\"adam\",loss=\"sparse_categorical_crossentropy\",metrics=[\"accuracy\"])\n\nhistory_2 = efficientnet_model.fit(x_train_scaled,y_train,epochs=1,batch_size=64,\n                        validation_data=(x_test_scaled,y_test))","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:49:40.985156Z","iopub.execute_input":"2023-12-16T09:49:40.985879Z","iopub.status.idle":"2023-12-16T09:51:25.060792Z","shell.execute_reply.started":"2023-12-16T09:49:40.985844Z","shell.execute_reply":"2023-12-16T09:51:25.059969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"loss, acc = efficientnet_model.evaluate(x_test_scaled,y_test)\nprint(\"Accuracy on Test Data:\",acc) \nloss ,acc = efficientnet_model.evaluate(x_train_scaled,y_train)\nprint(\"Accuracy on Train Data:\",acc)","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:52:05.889245Z","iopub.execute_input":"2023-12-16T09:52:05.88962Z","iopub.status.idle":"2023-12-16T09:53:11.745108Z","shell.execute_reply.started":"2023-12-16T09:52:05.889591Z","shell.execute_reply":"2023-12-16T09:53:11.74426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = efficientnet_model.predict(x_test_scaled)\ny_pred","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:53:28.721172Z","iopub.execute_input":"2023-12-16T09:53:28.722051Z","iopub.status.idle":"2023-12-16T09:53:36.269414Z","shell.execute_reply.started":"2023-12-16T09:53:28.722015Z","shell.execute_reply":"2023-12-16T09:53:36.268265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_label = [np.argmax(i) for i in y_pred]\ny_pred_label[:10]","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:53:48.432347Z","iopub.execute_input":"2023-12-16T09:53:48.432715Z","iopub.status.idle":"2023-12-16T09:53:48.441202Z","shell.execute_reply.started":"2023-12-16T09:53:48.432687Z","shell.execute_reply":"2023-12-16T09:53:48.440165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Classification Report:\\n\",classification_report(y_test,y_pred_label))","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:55:04.206101Z","iopub.execute_input":"2023-12-16T09:55:04.206866Z","iopub.status.idle":"2023-12-16T09:55:04.220918Z","shell.execute_reply.started":"2023-12-16T09:55:04.206832Z","shell.execute_reply":"2023-12-16T09:55:04.219848Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**prediction on the test dataset\n**","metadata":{}},{"cell_type":"code","source":"class_labels = ['CC', 'EC', 'HGSC', 'LGSC', 'MC']","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:55:19.04582Z","iopub.execute_input":"2023-12-16T09:55:19.046632Z","iopub.status.idle":"2023-12-16T09:55:19.050838Z","shell.execute_reply.started":"2023-12-16T09:55:19.046602Z","shell.execute_reply":"2023-12-16T09:55:19.049835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = efficientnet_model.predict(predict_test_array_scaled)\npredictions = [np.argmax(i) for i in predictions]\npredictions","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:55:47.795391Z","iopub.execute_input":"2023-12-16T09:55:47.796303Z","iopub.status.idle":"2023-12-16T09:55:48.934992Z","shell.execute_reply.started":"2023-12-16T09:55:47.796268Z","shell.execute_reply":"2023-12-16T09:55:48.933992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = \"/kaggle/input/UBC-OCEAN/sample_submission.csv\"\nN = pd.read_csv(path)\nN","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:56:10.433436Z","iopub.execute_input":"2023-12-16T09:56:10.434318Z","iopub.status.idle":"2023-12-16T09:56:10.452442Z","shell.execute_reply.started":"2023-12-16T09:56:10.434275Z","shell.execute_reply":"2023-12-16T09:56:10.451415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = \"/kaggle/input/UBC-OCEAN/test.csv\"\ntest = pd.read_csv(path)\ntest","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:56:23.62357Z","iopub.execute_input":"2023-12-16T09:56:23.624403Z","iopub.status.idle":"2023-12-16T09:56:23.639346Z","shell.execute_reply.started":"2023-12-16T09:56:23.624369Z","shell.execute_reply":"2023-12-16T09:56:23.638318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_file = pd.DataFrame()\nsubmission_file['image_id'] = [41]\nsubmission_file['label'] = [class_labels[i] for i in predictions]\n\nsubmission_file.to_csv(\"submission.csv\",index_label=False)","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:56:37.476412Z","iopub.execute_input":"2023-12-16T09:56:37.476819Z","iopub.status.idle":"2023-12-16T09:56:37.489331Z","shell.execute_reply.started":"2023-12-16T09:56:37.47679Z","shell.execute_reply":"2023-12-16T09:56:37.488363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"submission.csv\")\ndf","metadata":{"execution":{"iopub.status.busy":"2023-12-16T09:56:50.705604Z","iopub.execute_input":"2023-12-16T09:56:50.70622Z","iopub.status.idle":"2023-12-16T09:56:50.717462Z","shell.execute_reply.started":"2023-12-16T09:56:50.706189Z","shell.execute_reply":"2023-12-16T09:56:50.716148Z"},"trusted":true},"execution_count":null,"outputs":[]}]}