{"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 cv2\nimport matplotlib.pyplot as plt\nfrom skimage.color import gray2rgb\nimport pydicom as dicom\nfrom pydicom import dcmread\nimport numpy as np\nimport pandas as pd\nfrom glob import glob\nfrom tqdm.notebook import tqdm\nimport h5py\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder, LabelBinarizer, OneHotEncoder\nfrom sklearn.metrics import confusion_matrix, classification_report\nfrom tensorflow.keras.layers import Conv2D, MaxPool2D, BatchNormalization, Dense, Activation, Flatten, Dropout, Input\nfrom tensorflow.keras.applications import VGG19 as PTM_19, VGG16 as PTM_16\nfrom keras.models import Sequential\nfrom keras.models import Model\nfrom tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping, ReduceLROnPlateau\nfrom tensorflow.keras.optimizers import Adam as adm , SGD as sgd\nfrom tensorflow.keras.applications.vgg16 import preprocess_input as input16\nfrom tensorflow.keras.applications.vgg19 import preprocess_input as input19\nimport matplotlib.patches as patches\nfrom keras.utils.vis_utils import plot_model\nimport tensorflow as tf","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-08-06T12:26:50.936097Z","iopub.execute_input":"2021-08-06T12:26:50.936483Z","iopub.status.idle":"2021-08-06T12:26:56.694152Z","shell.execute_reply.started":"2021-08-06T12:26:50.936424Z","shell.execute_reply":"2021-08-06T12:26:56.693274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h5file_path = '../input/coviddetectiondataset/CovidDetectionTrainingData.h5'\nclasses_file_path = '../input/classes/classes.npy'","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:40:36.042292Z","iopub.execute_input":"2021-08-06T06:40:36.042603Z","iopub.status.idle":"2021-08-06T06:40:36.047392Z","shell.execute_reply.started":"2021-08-06T06:40:36.042575Z","shell.execute_reply":"2021-08-06T06:40:36.046411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h5Dataset = h5py.File(h5file_path, 'r')\nclasses = np.load(classes_file_path)","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:40:47.172184Z","iopub.execute_input":"2021-08-06T06:40:47.172511Z","iopub.status.idle":"2021-08-06T06:40:47.193834Z","shell.execute_reply.started":"2021-08-06T06:40:47.172483Z","shell.execute_reply":"2021-08-06T06:40:47.193043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_file_names = h5Dataset[\"data_file_names\"][:]\ndata_images = h5Dataset[\"data_images\"][:]\ndata_target_cc = h5Dataset[\"data_target_cc\"][:]\ndata_targets_bbox = h5Dataset[\"data_targets_bbox\"][:]\ndata_file_names.shape, data_images.shape, data_target_cc.shape, data_targets_bbox.shape","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:41:04.182928Z","iopub.execute_input":"2021-08-06T06:41:04.183245Z","iopub.status.idle":"2021-08-06T06:41:28.573281Z","shell.execute_reply.started":"2021-08-06T06:41:04.183217Z","shell.execute_reply":"2021-08-06T06:41:28.572215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_testing_split = train_test_split(data_images, data_target_cc, data_targets_bbox, data_file_names, test_size=0.3, random_state=42)\nX_train_images, X_test_images = training_testing_split[:2]\ny_train_clf, y_test_clf = training_testing_split[2:4]\ny_train_bbox, y_test_bbox = training_testing_split[4:6]\nfn_train, fn_test = training_testing_split[6:]","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:41:32.241756Z","iopub.execute_input":"2021-08-06T06:41:32.242113Z","iopub.status.idle":"2021-08-06T06:41:33.203432Z","shell.execute_reply.started":"2021-08-06T06:41:32.242085Z","shell.execute_reply":"2021-08-06T06:41:33.202435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train_images.shape, X_test_images.shape, y_train_clf.shape, y_test_clf.shape, y_train_bbox.shape, y_test_bbox.shape, fn_train.shape, fn_test.shape","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:41:43.119461Z","iopub.execute_input":"2021-08-06T06:41:43.119857Z","iopub.status.idle":"2021-08-06T06:41:43.127618Z","shell.execute_reply.started":"2021-08-06T06:41:43.119822Z","shell.execute_reply":"2021-08-06T06:41:43.126372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del data_images, data_target_cc, data_targets_bbox, data_file_names","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:41:58.607329Z","iopub.execute_input":"2021-08-06T06:41:58.607646Z","iopub.status.idle":"2021-08-06T06:41:58.619258Z","shell.execute_reply.started":"2021-08-06T06:41:58.607616Z","shell.execute_reply":"2021-08-06T06:41:58.618413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mtf = tf.keras.callbacks","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:42:17.025328Z","iopub.execute_input":"2021-08-06T06:42:17.02564Z","iopub.status.idle":"2021-08-06T06:42:17.029994Z","shell.execute_reply.started":"2021-08-06T06:42:17.025608Z","shell.execute_reply":"2021-08-06T06:42:17.02908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"GPU_DEVICE=\"/device:GPU:0\"","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:42:18.793998Z","iopub.execute_input":"2021-08-06T06:42:18.79432Z","iopub.status.idle":"2021-08-06T06:42:18.798396Z","shell.execute_reply.started":"2021-08-06T06:42:18.794291Z","shell.execute_reply":"2021-08-06T06:42:18.79747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ptm_19_weights_path = '../input/vgg19weights1/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5'","metadata":{"execution":{"iopub.status.busy":"2021-08-06T12:31:43.988215Z","iopub.execute_input":"2021-08-06T12:31:43.988593Z","iopub.status.idle":"2021-08-06T12:31:43.994852Z","shell.execute_reply.started":"2021-08-06T12:31:43.988555Z","shell.execute_reply":"2021-08-06T12:31:43.992197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ptm_19 = PTM_19(weights=ptm_19_weights_path,\n            include_top=False, pooling='avg')\nptm_19.trainable = False","metadata":{"execution":{"iopub.status.busy":"2021-08-06T12:31:49.427255Z","iopub.execute_input":"2021-08-06T12:31:49.427661Z","iopub.status.idle":"2021-08-06T12:31:51.653891Z","shell.execute_reply.started":"2021-08-06T12:31:49.427629Z","shell.execute_reply":"2021-08-06T12:31:51.652826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ptm_19.summary()","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:42:38.329641Z","iopub.execute_input":"2021-08-06T06:42:38.329995Z","iopub.status.idle":"2021-08-06T06:42:38.347842Z","shell.execute_reply.started":"2021-08-06T06:42:38.329966Z","shell.execute_reply":"2021-08-06T06:42:38.345974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_features_19 = []\nprint(\"Extracting Training Features ...\")\nfor train_image_19 in tqdm(X_train_images):\n  with tf.device(GPU_DEVICE):\n    img_19 = np.expand_dims(train_image_19, axis=0)\n    training_feature_19 = ptm_19.predict(input19(img_19))[0]\n    training_features_19.append(training_feature_19)\ntraining_features_19 = np.array(training_features_19)\nprint(\"Done Extracting Training Features.\")","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:42:49.326055Z","iopub.execute_input":"2021-08-06T06:42:49.326405Z","iopub.status.idle":"2021-08-06T06:45:35.236307Z","shell.execute_reply.started":"2021-08-06T06:42:49.326373Z","shell.execute_reply":"2021-08-06T06:45:35.235484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_features_19.shape","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:48:15.402032Z","iopub.execute_input":"2021-08-06T06:48:15.402378Z","iopub.status.idle":"2021-08-06T06:48:15.408232Z","shell.execute_reply.started":"2021-08-06T06:48:15.402338Z","shell.execute_reply":"2021-08-06T06:48:15.407334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testing_features_19 = []\nprint(\"Extracting Testing Features ...\")\nfor test_image_19 in tqdm(X_test_images):\n  with tf.device(GPU_DEVICE):\n    tst_img_19 = np.expand_dims(test_image_19, axis=0)\n    testing_feature_19 = ptm_19.predict(input19(tst_img_19))[0]\n    testing_features_19.append(testing_feature_19)\ntesting_features_19 = np.array(testing_features_19)\nprint(\"Done Extracting Testing Features.\")","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:48:17.02084Z","iopub.execute_input":"2021-08-06T06:48:17.021164Z","iopub.status.idle":"2021-08-06T06:49:24.205504Z","shell.execute_reply.started":"2021-08-06T06:48:17.021136Z","shell.execute_reply":"2021-08-06T06:49:24.204498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testing_features_19.shape","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:49:28.327455Z","iopub.execute_input":"2021-08-06T06:49:28.327795Z","iopub.status.idle":"2021-08-06T06:49:28.333481Z","shell.execute_reply.started":"2021-08-06T06:49:28.327741Z","shell.execute_reply":"2021-08-06T06:49:28.3325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_19_clf = Sequential([\n    Dense(1024, input_shape=(512,)),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(512),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(256),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(256),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(256),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.3),\n    Dense(4),\n    Activation('softmax'),\n])\n\nadam_lr_clf = adm(learning_rate =1e-4,  beta_1=0.9, beta_2=0.999)\nmodel_19_clf.compile(optimizer = adam_lr_clf, loss = 'categorical_crossentropy', metrics = ['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:49:31.747752Z","iopub.execute_input":"2021-08-06T06:49:31.748098Z","iopub.status.idle":"2021-08-06T06:49:31.893111Z","shell.execute_reply.started":"2021-08-06T06:49:31.748068Z","shell.execute_reply":"2021-08-06T06:49:31.89226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_19_bbox = Sequential([\n    Dense(1024, input_shape=(512,)),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(512),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(256),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(256),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.5),\n    Dense(256),\n    Activation('relu'),\n    BatchNormalization(),\n    Dropout(0.3),\n    Dense(4),\n    Activation('sigmoid'),\n])\n\nadam_lr_bbox = adm(learning_rate = 0.001, beta_1=0.9, beta_2=0.999, decay=0.001)\nmodel_19_bbox.compile(loss='mean_squared_error', optimizer=adam_lr_bbox, metrics=['mean_absolute_error'])","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:49:38.459082Z","iopub.execute_input":"2021-08-06T06:49:38.45941Z","iopub.status.idle":"2021-08-06T06:49:38.592881Z","shell.execute_reply.started":"2021-08-06T06:49:38.459378Z","shell.execute_reply":"2021-08-06T06:49:38.591978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"epochs = 63\nbatch_size = 8","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:50:13.530603Z","iopub.execute_input":"2021-08-06T06:50:13.530942Z","iopub.status.idle":"2021-08-06T06:50:13.535691Z","shell.execute_reply.started":"2021-08-06T06:50:13.530911Z","shell.execute_reply":"2021-08-06T06:50:13.53443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with tf.device(GPU_DEVICE):\n  history_clf = model_19_clf.fit(training_features_19, y_train_clf,\n                                 validation_data=(testing_features_19, y_test_clf),\n                                 batch_size=batch_size,\n                                 epochs=epochs, verbose=1, shuffle=True, )#, shuffle=True, callbacks=[model_checkpoint_callback])","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:50:17.093021Z","iopub.execute_input":"2021-08-06T06:50:17.093442Z","iopub.status.idle":"2021-08-06T06:53:32.469264Z","shell.execute_reply.started":"2021-08-06T06:50:17.093404Z","shell.execute_reply":"2021-08-06T06:53:32.468433Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history_clf_19 = history_clf.history\n\nprint(\"VGG_19 CLASSIFICATION ACCURACY GRAPH\")\nplt.plot(history_clf_19['accuracy'])\nplt.plot(history_clf_19['val_accuracy'])\nplt.title('Accuracy Of VGG-19')\nplt.ylabel('accuracy')\nplt.xlabel('epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:53:36.662865Z","iopub.execute_input":"2021-08-06T06:53:36.663182Z","iopub.status.idle":"2021-08-06T06:53:36.824647Z","shell.execute_reply.started":"2021-08-06T06:53:36.663154Z","shell.execute_reply":"2021-08-06T06:53:36.823693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"VGG_19 CLASSIFICATION LOSS GRAPH\")\nplt.plot(history_clf_19['loss'])\nplt.plot(history_clf_19['val_loss'])\nplt.title('Loss Of VGG-19')\nplt.ylabel('loss')\nplt.xlabel('epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:53:41.041979Z","iopub.execute_input":"2021-08-06T06:53:41.042315Z","iopub.status.idle":"2021-08-06T06:53:41.188799Z","shell.execute_reply.started":"2021-08-06T06:53:41.042272Z","shell.execute_reply":"2021-08-06T06:53:41.187624Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"evaluation_19 = model_19_clf.evaluate(testing_features_19, y_test_clf)","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:53:45.24069Z","iopub.execute_input":"2021-08-06T06:53:45.24103Z","iopub.status.idle":"2021-08-06T06:53:45.40892Z","shell.execute_reply.started":"2021-08-06T06:53:45.240999Z","shell.execute_reply":"2021-08-06T06:53:45.407917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with tf.device(GPU_DEVICE):\n  history_bbox = model_19_bbox.fit(training_features_19, y_train_bbox, verbose=1, batch_size=batch_size, epochs=epochs, validation_data=(testing_features_19, y_test_bbox))","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:53:49.207459Z","iopub.execute_input":"2021-08-06T06:53:49.207812Z","iopub.status.idle":"2021-08-06T06:57:00.920227Z","shell.execute_reply.started":"2021-08-06T06:53:49.207758Z","shell.execute_reply":"2021-08-06T06:57:00.917921Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history_bbox_19 = history_bbox.history\n\nprint(\"VGG_19 BOUNDING BOX REGRESSION LOSS GRAPH\")\nplt.plot(history_bbox_19['loss'])\nplt.plot(history_bbox_19['val_loss'])\nplt.title('Loss Of VGG-19')\nplt.ylabel('loss')\nplt.xlabel('epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:57:32.5836Z","iopub.execute_input":"2021-08-06T06:57:32.583946Z","iopub.status.idle":"2021-08-06T06:57:32.801011Z","shell.execute_reply.started":"2021-08-06T06:57:32.583917Z","shell.execute_reply":"2021-08-06T06:57:32.797191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"VGG_19 BOUNDING BOX REGRESSION MEAN ABSOLUTE ERROR GRAPH\")\nplt.plot(history_bbox_19['mean_absolute_error'])\nplt.plot(history_bbox_19['val_mean_absolute_error'])\nplt.title('MAE Of VGG-19')\nplt.ylabel('loss')\nplt.xlabel('epoch')\nplt.legend(['train', 'test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:57:35.951268Z","iopub.execute_input":"2021-08-06T06:57:35.951617Z","iopub.status.idle":"2021-08-06T06:57:36.092087Z","shell.execute_reply.started":"2021-08-06T06:57:35.951587Z","shell.execute_reply":"2021-08-06T06:57:36.091061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"index = 135\ntest_img = testing_features_19[index]\ntest_img = np.expand_dims(test_img, axis=0)\npred_clf = model_19_clf.predict(test_img)\npred_bbox = model_19_bbox.predict(test_img)","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:57:40.444358Z","iopub.execute_input":"2021-08-06T06:57:40.444683Z","iopub.status.idle":"2021-08-06T06:57:40.735208Z","shell.execute_reply.started":"2021-08-06T06:57:40.444654Z","shell.execute_reply":"2021-08-06T06:57:40.734256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_clf[0], y_test_clf[index], pred_bbox[0], y_test_bbox[index]","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:57:59.875654Z","iopub.execute_input":"2021-08-06T06:57:59.876057Z","iopub.status.idle":"2021-08-06T06:57:59.887483Z","shell.execute_reply.started":"2021-08-06T06:57:59.876023Z","shell.execute_reply":"2021-08-06T06:57:59.886633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testing_img_path = '../input/siim-covid19-detection/test/'","metadata":{"execution":{"iopub.status.busy":"2021-08-06T06:58:22.312178Z","iopub.execute_input":"2021-08-06T06:58:22.312494Z","iopub.status.idle":"2021-08-06T06:58:22.317401Z","shell.execute_reply.started":"2021-08-06T06:58:22.312466Z","shell.execute_reply":"2021-08-06T06:58:22.315306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_images_fp = glob(f'{testing_img_path}*/*/*')","metadata":{"execution":{"iopub.status.busy":"2021-08-06T07:07:11.662007Z","iopub.execute_input":"2021-08-06T07:07:11.662397Z","iopub.status.idle":"2021-08-06T07:07:15.652377Z","shell.execute_reply.started":"2021-08-06T07:07:11.662347Z","shell.execute_reply":"2021-08-06T07:07:15.651533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_size = (224,224)","metadata":{"execution":{"iopub.status.busy":"2021-08-06T07:07:36.792434Z","iopub.execute_input":"2021-08-06T07:07:36.792753Z","iopub.status.idle":"2021-08-06T07:07:36.796753Z","shell.execute_reply.started":"2021-08-06T07:07:36.792724Z","shell.execute_reply":"2021-08-06T07:07:36.795663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"results = []\nfor pred_img_fp in tqdm(pred_images_fp):\n  try:\n    with tf.device(GPU_DEVICE):\n      sutdy_id = f'{pred_img_fp.split(\"/\")[5]}_study'\n      ds = dcmread(pred_img_fp) # reading image from the created path\n      image = np.array(ds.pixel_array) # converting image pixels into numpy array\n      image = cv2.resize(image, image_size) # resizing image\n      image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB) #convert to 3 channel\n      image = np.expand_dims(image, axis=0)\n      image = ptm_19.predict(input19(image))[0]\n      image = np.expand_dims(image, axis=0)\n      clf_pred = model_19_clf.predict(image)\n      clf_pred_val = clf_pred[0]\n      clf_pred_val = np.argmax(clf_pred_val)\n      class_pred = classes[clf_pred_val]\n      confidence = clf_pred[0][clf_pred_val]\n      bbox = model_19_bbox.predict(image)\n      x,y,w,h = bbox[0]\n      pred_str = None\n      if class_pred == classes[0]:\n        pred_str = f'{class_pred} {confidence} 0 0 0 0'\n      else:\n        pred_str = f'{class_pred} {confidence} {x} {y} {w} {h}'\n      results.append([sutdy_id, pred_str])\n  except:\n    pass#print(\"Exception Occured\")","metadata":{"execution":{"iopub.status.busy":"2021-08-06T07:07:38.775707Z","iopub.execute_input":"2021-08-06T07:07:38.776057Z","iopub.status.idle":"2021-08-06T07:13:24.390091Z","shell.execute_reply.started":"2021-08-06T07:07:38.776027Z","shell.execute_reply":"2021-08-06T07:13:24.389333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataframe = pd.DataFrame(results, columns=['id', 'PredictionString'])\ndataframe.head(20)","metadata":{"execution":{"iopub.status.busy":"2021-08-06T07:13:29.762366Z","iopub.execute_input":"2021-08-06T07:13:29.762724Z","iopub.status.idle":"2021-08-06T07:13:29.793826Z","shell.execute_reply.started":"2021-08-06T07:13:29.76269Z","shell.execute_reply":"2021-08-06T07:13:29.792865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataframe.shape","metadata":{"execution":{"iopub.status.busy":"2021-08-06T07:13:34.72422Z","iopub.execute_input":"2021-08-06T07:13:34.72455Z","iopub.status.idle":"2021-08-06T07:13:34.731746Z","shell.execute_reply.started":"2021-08-06T07:13:34.724522Z","shell.execute_reply":"2021-08-06T07:13:34.730868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataframe.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2021-08-06T07:13:37.227584Z","iopub.execute_input":"2021-08-06T07:13:37.22799Z","iopub.status.idle":"2021-08-06T07:13:37.244047Z","shell.execute_reply.started":"2021-08-06T07:13:37.227954Z","shell.execute_reply":"2021-08-06T07:13:37.243166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}