{"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":"markdown","source":"# Histopathic Cancer Detection (HCD)\n### Taylor Kern","metadata":{}},{"cell_type":"markdown","source":"# Prepare Enviornment","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nimport pickle\nimport os\n\n\nfrom sklearn.model_selection import train_test_split\n\nimport tensorflow as tf\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow import keras\nfrom tensorflow.keras.layers import * \n\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:51.748529Z","iopub.execute_input":"2022-03-28T23:27:51.749156Z","iopub.status.idle":"2022-03-28T23:27:57.528151Z","shell.execute_reply.started":"2022-03-28T23:27:51.749113Z","shell.execute_reply":"2022-03-28T23:27:57.527392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Load Training DataFrame","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv('../input/histopathologic-cancer-detection/train_labels.csv', dtype=str)\nprint(train.shape)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:57.529961Z","iopub.execute_input":"2022-03-28T23:27:57.530319Z","iopub.status.idle":"2022-03-28T23:27:57.966192Z","shell.execute_reply.started":"2022-03-28T23:27:57.530281Z","shell.execute_reply":"2022-03-28T23:27:57.965435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:57.967466Z","iopub.execute_input":"2022-03-28T23:27:57.967906Z","iopub.status.idle":"2022-03-28T23:27:57.984489Z","shell.execute_reply.started":"2022-03-28T23:27:57.967868Z","shell.execute_reply":"2022-03-28T23:27:57.983681Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.id = train.id + '.tif'","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:57.986457Z","iopub.execute_input":"2022-03-28T23:27:57.986713Z","iopub.status.idle":"2022-03-28T23:27:58.031955Z","shell.execute_reply.started":"2022-03-28T23:27:57.986678Z","shell.execute_reply":"2022-03-28T23:27:58.031228Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:58.033333Z","iopub.execute_input":"2022-03-28T23:27:58.033791Z","iopub.status.idle":"2022-03-28T23:27:58.044272Z","shell.execute_reply.started":"2022-03-28T23:27:58.033754Z","shell.execute_reply":"2022-03-28T23:27:58.043413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Label Distribution","metadata":{}},{"cell_type":"code","source":"(train.label.value_counts() / len(train)).to_frame().sort_index().T","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:58.045867Z","iopub.execute_input":"2022-03-28T23:27:58.046656Z","iopub.status.idle":"2022-03-28T23:27:58.085584Z","shell.execute_reply.started":"2022-03-28T23:27:58.046614Z","shell.execute_reply":"2022-03-28T23:27:58.084821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Extract Images","metadata":{}},{"cell_type":"code","source":"train_path = \"../input/histopathologic-cancer-detection/train\"\n\nsample = train.sample(n=16).reset_index()\n\nplt.figure(figsize=(6,6))\n\nfor i, row in sample.iterrows():\n\n    img = mpimg.imread(f'../input/histopathologic-cancer-detection/train/{row.id}')    \n    label = row.label\n\n    plt.subplot(4,4,i+1)\n    plt.imshow(img)\n    plt.text(0, -5, f'Class {label}', color='k')\n        \n    plt.axis('off')\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:58.086948Z","iopub.execute_input":"2022-03-28T23:27:58.087322Z","iopub.status.idle":"2022-03-28T23:27:58.886277Z","shell.execute_reply.started":"2022-03-28T23:27:58.087286Z","shell.execute_reply":"2022-03-28T23:27:58.884365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Training and Validation Sets","metadata":{}},{"cell_type":"code","source":"train_df, valid_df = train_test_split(train, test_size=0.2, random_state=1, stratify=train.label)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:58.888116Z","iopub.execute_input":"2022-03-28T23:27:58.888384Z","iopub.status.idle":"2022-03-28T23:27:59.191696Z","shell.execute_reply.started":"2022-03-28T23:27:58.888351Z","shell.execute_reply":"2022-03-28T23:27:59.190953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Generators","metadata":{}},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(rescale=1/255)\nvalidation_datagen = ImageDataGenerator(rescale=1/255)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:59.193132Z","iopub.execute_input":"2022-03-28T23:27:59.193542Z","iopub.status.idle":"2022-03-28T23:27:59.198069Z","shell.execute_reply.started":"2022-03-28T23:27:59.193502Z","shell.execute_reply":"2022-03-28T23:27:59.197175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"BATCH_SIZE = 64\n\ntrain_loader = train_datagen.flow_from_dataframe(\n    dataframe = valid_df,\n    directory = train_path,\n    x_col = 'id',\n    y_col = 'label',\n    batch_size = BATCH_SIZE,\n    seed = 1,\n    shuffle = True,\n    class_mode = 'categorical',\n    target_size = (96,96)\n)\n\nvalid_loader = train_datagen.flow_from_dataframe(\n    dataframe = valid_df,\n    directory = train_path,\n    x_col = 'id',\n    y_col = 'label',\n    batch_size = BATCH_SIZE,\n    seed = 1,\n    shuffle = True,\n    class_mode = 'categorical',\n    target_size = (96,96)\n)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:27:59.199807Z","iopub.execute_input":"2022-03-28T23:27:59.200193Z","iopub.status.idle":"2022-03-28T23:29:59.665307Z","shell.execute_reply.started":"2022-03-28T23:27:59.200156Z","shell.execute_reply":"2022-03-28T23:29:59.663846Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"TR_STEPS = len(train_loader)\nVA_STEPS = len(valid_loader)\n\nprint(TR_STEPS)\nprint(VA_STEPS)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:29:59.666919Z","iopub.execute_input":"2022-03-28T23:29:59.66724Z","iopub.status.idle":"2022-03-28T23:29:59.67377Z","shell.execute_reply.started":"2022-03-28T23:29:59.667205Z","shell.execute_reply":"2022-03-28T23:29:59.672098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Build and Train","metadata":{}},{"cell_type":"code","source":"os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:29:59.6752Z","iopub.execute_input":"2022-03-28T23:29:59.675546Z","iopub.status.idle":"2022-03-28T23:29:59.684824Z","shell.execute_reply.started":"2022-03-28T23:29:59.675511Z","shell.execute_reply":"2022-03-28T23:29:59.683875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.random.seed(1)\ntf.random.set_seed(1)\n\ncnn = Sequential([\n    Conv2D(16, (3,3), activation = 'relu', padding = 'same', input_shape=(96,96,3)),\n    Conv2D(16, (3,3), activation = 'relu', padding = 'same'),\n    MaxPooling2D(2,2),\n    Dropout(0.5),\n    BatchNormalization(),\n\n    Conv2D(64, (3,3), activation = 'relu', padding = 'same'),\n    Conv2D(64, (3,3), activation = 'relu', padding = 'same'),\n    MaxPooling2D(2,2),\n    Dropout(0.5),\n    BatchNormalization(),\n    \n    Conv2D(128, (3,3), activation = 'relu', padding = 'same'),\n    Conv2D(128, (3,3), activation = 'relu', padding = 'same'),\n    MaxPooling2D(2,2),\n    Dropout(0.5),\n    BatchNormalization(),\n\n    Flatten(),\n    \n    Dense(16, activation='relu'),\n    Dropout(0.5),\n    Dense(8, activation='relu'),\n    Dropout(0.5),\n    BatchNormalization(),\n    Dense(2, activation='softmax')\n])\n\ncnn.summary()","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:29:59.686274Z","iopub.execute_input":"2022-03-28T23:29:59.686475Z","iopub.status.idle":"2022-03-28T23:30:01.948179Z","shell.execute_reply.started":"2022-03-28T23:29:59.686451Z","shell.execute_reply":"2022-03-28T23:30:01.947491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"opt = tf.keras.optimizers.Adam(0.001)\ncnn.compile(loss='categorical_crossentropy', optimizer=opt, metrics=['accuracy', tf.keras.metrics.AUC()])","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:10.59434Z","iopub.execute_input":"2022-03-17T18:31:10.594576Z","iopub.status.idle":"2022-03-17T18:31:10.614835Z","shell.execute_reply.started":"2022-03-17T18:31:10.594541Z","shell.execute_reply":"2022-03-17T18:31:10.614221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time \n\nh1 = cnn.fit(\n    x = train_loader, \n    steps_per_epoch = TR_STEPS, \n    epochs = 40,\n    validation_data = valid_loader, \n    validation_steps = VA_STEPS, \n    verbose = 1\n)","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:10.616082Z","iopub.execute_input":"2022-03-17T18:31:10.617179Z","iopub.status.idle":"2022-03-17T18:31:19.35441Z","shell.execute_reply.started":"2022-03-17T18:31:10.61714Z","shell.execute_reply":"2022-03-17T18:31:19.353713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = h1.history\nprint(history.keys())","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.355586Z","iopub.execute_input":"2022-03-17T18:31:19.355916Z","iopub.status.idle":"2022-03-17T18:31:19.375837Z","shell.execute_reply.started":"2022-03-17T18:31:19.355866Z","shell.execute_reply":"2022-03-17T18:31:19.374694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"epoch_range = range(1, len(history['loss'])+1)\n\nplt.figure(figsize=[14,4])\nplt.subplot(1,3,1)\nplt.plot(epoch_range, history['loss'], label='Training')\nplt.plot(epoch_range, history['val_loss'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('Loss'); plt.title('Loss')\nplt.legend()\nplt.subplot(1,3,2)\nplt.plot(epoch_range, history['accuracy'], label='Training')\nplt.plot(epoch_range, history['val_accuracy'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('Accuracy'); plt.title('Accuracy')\nplt.legend()\nplt.subplot(1,3,3)\nplt.plot(epoch_range, history['auc'], label='Training')\nplt.plot(epoch_range, history['val_auc'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('AUC'); plt.title('AUC')\nplt.legend()\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.376826Z","iopub.status.idle":"2022-03-17T18:31:19.37765Z","shell.execute_reply.started":"2022-03-17T18:31:19.377409Z","shell.execute_reply":"2022-03-17T18:31:19.377436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Train 2  ","metadata":{}},{"cell_type":"code","source":"tf.keras.backend.set_value(cnn.optimizer.learning_rate, 0.0001)","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.378844Z","iopub.status.idle":"2022-03-17T18:31:19.379635Z","shell.execute_reply.started":"2022-03-17T18:31:19.379371Z","shell.execute_reply":"2022-03-17T18:31:19.379396Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time \n\nh2 = cnn.fit(\n    x = train_loader, \n    steps_per_epoch = TR_STEPS, \n    epochs = 30,\n    validation_data = valid_loader, \n    validation_steps = VA_STEPS, \n    verbose = 1\n)","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.380693Z","iopub.status.idle":"2022-03-17T18:31:19.381445Z","shell.execute_reply.started":"2022-03-17T18:31:19.381207Z","shell.execute_reply":"2022-03-17T18:31:19.381236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for k in history.keys():\n    history[k] += h2.history[k]\n\nepoch_range = range(1, len(history['loss'])+1)\n\nplt.figure(figsize=[14,4])\nplt.subplot(1,3,1)\nplt.plot(epoch_range, history['loss'], label='Training')\nplt.plot(epoch_range, history['val_loss'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('Loss'); plt.title('Loss')\nplt.legend()\nplt.subplot(1,3,2)\nplt.plot(epoch_range, history['accuracy'], label='Training')\nplt.plot(epoch_range, history['val_accuracy'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('Accuracy'); plt.title('Accuracy')\nplt.legend()\nplt.subplot(1,3,3)\nplt.plot(epoch_range, history['auc'], label='Training')\nplt.plot(epoch_range, history['val_auc'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('AUC'); plt.title('AUC')\nplt.legend()\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.382515Z","iopub.status.idle":"2022-03-17T18:31:19.383211Z","shell.execute_reply.started":"2022-03-17T18:31:19.382979Z","shell.execute_reply":"2022-03-17T18:31:19.383008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Training 3","metadata":{}},{"cell_type":"code","source":"tf.keras.backend.set_value(cnn.optimizer.learning_rate, 0.0001)","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.384417Z","iopub.status.idle":"2022-03-17T18:31:19.385151Z","shell.execute_reply.started":"2022-03-17T18:31:19.384925Z","shell.execute_reply":"2022-03-17T18:31:19.384949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time \n\nh3 = cnn.fit(\n    x = train_loader, \n    steps_per_epoch = TR_STEPS, \n    epochs = 20,\n    validation_data = valid_loader, \n    validation_steps = VA_STEPS, \n    verbose = 1\n)","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.386278Z","iopub.status.idle":"2022-03-17T18:31:19.386986Z","shell.execute_reply.started":"2022-03-17T18:31:19.386726Z","shell.execute_reply":"2022-03-17T18:31:19.386754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for k in history.keys():\n    history[k] += h3.history[k]\n\nepoch_range = range(1, len(history['loss'])+1)\n\nplt.figure(figsize=[14,4])\nplt.subplot(1,3,1)\nplt.plot(epoch_range, history['loss'], label='Training')\nplt.plot(epoch_range, history['val_loss'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('Loss'); plt.title('Loss')\nplt.legend()\nplt.subplot(1,3,2)\nplt.plot(epoch_range, history['accuracy'], label='Training')\nplt.plot(epoch_range, history['val_accuracy'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('Accuracy'); plt.title('Accuracy')\nplt.legend()\nplt.subplot(1,3,3)\nplt.plot(epoch_range, history['auc'], label='Training')\nplt.plot(epoch_range, history['val_auc'], label='Validation')\nplt.xlabel('Epoch'); plt.ylabel('AUC'); plt.title('AUC')\nplt.legend()\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.388126Z","iopub.status.idle":"2022-03-17T18:31:19.388853Z","shell.execute_reply.started":"2022-03-17T18:31:19.388622Z","shell.execute_reply":"2022-03-17T18:31:19.388649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cnn.save('HCDv01.h5')\npickle.dump(history, open(f'HCDv01.pkl', 'wb'))","metadata":{"execution":{"iopub.status.busy":"2022-03-17T18:31:19.390015Z","iopub.status.idle":"2022-03-17T18:31:19.39073Z","shell.execute_reply.started":"2022-03-17T18:31:19.39049Z","shell.execute_reply":"2022-03-17T18:31:19.390517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submission","metadata":{}},{"cell_type":"code","source":"test = pd.read_csv('../input/histopathologic-cancer-detection/sample_submission.csv')\n\nprint('Test Set Size:', test.shape)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:30:01.949537Z","iopub.execute_input":"2022-03-28T23:30:01.949784Z","iopub.status.idle":"2022-03-28T23:30:02.13827Z","shell.execute_reply.started":"2022-03-28T23:30:01.94975Z","shell.execute_reply":"2022-03-28T23:30:02.13751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test['filename'] = test.id + '.tif'","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:56:18.367885Z","iopub.execute_input":"2022-03-28T23:56:18.368519Z","iopub.status.idle":"2022-03-28T23:56:18.380493Z","shell.execute_reply.started":"2022-03-28T23:56:18.368481Z","shell.execute_reply":"2022-03-28T23:56:18.379734Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:56:19.908318Z","iopub.execute_input":"2022-03-28T23:56:19.908578Z","iopub.status.idle":"2022-03-28T23:56:19.917594Z","shell.execute_reply.started":"2022-03-28T23:56:19.908549Z","shell.execute_reply":"2022-03-28T23:56:19.916907Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_path = \"../input/histopathologic-cancer-detection/test\"\nprint('Test Images:', len(os.listdir(test_path)))","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:56:21.428524Z","iopub.execute_input":"2022-03-28T23:56:21.429222Z","iopub.status.idle":"2022-03-28T23:56:21.466303Z","shell.execute_reply.started":"2022-03-28T23:56:21.429181Z","shell.execute_reply":"2022-03-28T23:56:21.46551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"BATCH_SIZE = 64\n\ntest_datagen = ImageDataGenerator(rescale=1/255)\n\ntest_loader = test_datagen.flow_from_dataframe(\n    dataframe = test,\n    directory = test_path,\n    x_col = 'filename',\n    batch_size = BATCH_SIZE,\n    shuffle = False,\n    class_mode = None,\n    target_size = (96,96)\n)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:56:22.574197Z","iopub.execute_input":"2022-03-28T23:56:22.574684Z","iopub.status.idle":"2022-03-28T23:59:07.776608Z","shell.execute_reply.started":"2022-03-28T23:56:22.574643Z","shell.execute_reply":"2022-03-28T23:59:07.775875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_probs = cnn.predict(test_loader)\nprint(test_probs.shape)","metadata":{"execution":{"iopub.status.busy":"2022-03-28T23:59:07.777985Z","iopub.execute_input":"2022-03-28T23:59:07.778981Z","iopub.status.idle":"2022-03-29T00:06:36.007269Z","shell.execute_reply.started":"2022-03-28T23:59:07.77894Z","shell.execute_reply":"2022-03-29T00:06:36.00642Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(test_loader))\n","metadata":{"execution":{"iopub.status.busy":"2022-03-29T00:07:01.595801Z","iopub.execute_input":"2022-03-29T00:07:01.596504Z","iopub.status.idle":"2022-03-29T00:07:01.600599Z","shell.execute_reply.started":"2022-03-29T00:07:01.596466Z","shell.execute_reply":"2022-03-29T00:07:01.599816Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(test_probs[:10,].round(2))\n","metadata":{"execution":{"iopub.status.busy":"2022-03-29T00:07:03.816662Z","iopub.execute_input":"2022-03-29T00:07:03.817202Z","iopub.status.idle":"2022-03-29T00:07:03.822851Z","shell.execute_reply.started":"2022-03-29T00:07:03.817165Z","shell.execute_reply":"2022-03-29T00:07:03.822087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_pred = np.argmax(test_probs, axis=1)\nprint(test_pred[:10])","metadata":{"execution":{"iopub.status.busy":"2022-03-29T00:07:04.840338Z","iopub.execute_input":"2022-03-29T00:07:04.840892Z","iopub.status.idle":"2022-03-29T00:07:04.846539Z","shell.execute_reply.started":"2022-03-29T00:07:04.840848Z","shell.execute_reply":"2022-03-29T00:07:04.845714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Prepare Submission","metadata":{}},{"cell_type":"code","source":"submission = pd.read_csv('../input/histopathologic-cancer-detection/sample_submission.csv')\nsubmission.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-29T00:07:07.039234Z","iopub.execute_input":"2022-03-29T00:07:07.041413Z","iopub.status.idle":"2022-03-29T00:07:07.097029Z","shell.execute_reply.started":"2022-03-29T00:07:07.041374Z","shell.execute_reply":"2022-03-29T00:07:07.09634Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.label = test_probs[:,1]\nsubmission.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-29T00:07:07.290015Z","iopub.execute_input":"2022-03-29T00:07:07.290489Z","iopub.status.idle":"2022-03-29T00:07:07.30288Z","shell.execute_reply.started":"2022-03-29T00:07:07.290453Z","shell.execute_reply":"2022-03-29T00:07:07.302045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', header=True, index=False)","metadata":{"execution":{"iopub.status.busy":"2022-03-29T00:07:07.576779Z","iopub.execute_input":"2022-03-29T00:07:07.57749Z","iopub.status.idle":"2022-03-29T00:07:07.785876Z","shell.execute_reply.started":"2022-03-29T00:07:07.577453Z","shell.execute_reply":"2022-03-29T00:07:07.785134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}