{"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":"pip install keras-utils","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:51:36.742661Z","iopub.execute_input":"2021-07-05T06:51:36.743068Z","iopub.status.idle":"2021-07-05T06:51:46.498617Z","shell.execute_reply.started":"2021-07-05T06:51:36.742981Z","shell.execute_reply":"2021-07-05T06:51:46.497700Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport os\nimport keras\nfrom keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten\nfrom keras.layers import Conv2D, MaxPooling2D\nimport keras_utils\nfrom keras.preprocessing import image\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split\nfrom keras.utils.np_utils import to_categorical\nfrom tqdm import tqdm","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:51:46.501801Z","iopub.execute_input":"2021-07-05T06:51:46.502067Z","iopub.status.idle":"2021-07-05T06:51:52.260895Z","shell.execute_reply.started":"2021-07-05T06:51:46.502038Z","shell.execute_reply":"2021-07-05T06:51:52.259938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"traindf = pd.read_csv('../input/dataset/traindf.csv')\ntraindf","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:51:52.262923Z","iopub.execute_input":"2021-07-05T06:51:52.263304Z","iopub.status.idle":"2021-07-05T06:51:52.357804Z","shell.execute_reply.started":"2021-07-05T06:51:52.263264Z","shell.execute_reply":"2021-07-05T06:51:52.356894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### reading train images","metadata":{}},{"cell_type":"code","source":"path = \"../input/siim-covid19-resized-to-256px-jpg/train\"\nimgs=os.listdir(path)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:51:52.359489Z","iopub.execute_input":"2021-07-05T06:51:52.359827Z","iopub.status.idle":"2021-07-05T06:51:52.576102Z","shell.execute_reply.started":"2021-07-05T06:51:52.359792Z","shell.execute_reply":"2021-07-05T06:51:52.575151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images = []\nfor i in range(traindf.shape[0]):\n    kk = traindf[i:i+1]\n    #print(kk)\n    img = kk['id']\n    img = img[i]\n    imgf = img + '.jpg'\n    imgfile = os.path.join(path,imgf)\n    #print(imgfile)\n    imgg = cv2.imread(imgfile)\n    images.append(imgg)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:51:52.578197Z","iopub.execute_input":"2021-07-05T06:51:52.581320Z","iopub.status.idle":"2021-07-05T06:52:24.345109Z","shell.execute_reply.started":"2021-07-05T06:51:52.581273Z","shell.execute_reply":"2021-07-05T06:52:24.344270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Study Train","metadata":{}},{"cell_type":"code","source":"studyTrain = traindf.drop([\"Unnamed: 0\",\"boxes\", \"label\", \"Olabel\", \"integer_Olabel\"],axis=1)\nstudyTrain","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:24.346489Z","iopub.execute_input":"2021-07-05T06:52:24.346836Z","iopub.status.idle":"2021-07-05T06:52:24.369437Z","shell.execute_reply.started":"2021-07-05T06:52:24.346799Z","shell.execute_reply":"2021-07-05T06:52:24.368423Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##### preparing data for modeling","metadata":{}},{"cell_type":"code","source":"images=np.array(images)\nimages.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:24.371446Z","iopub.execute_input":"2021-07-05T06:52:24.371985Z","iopub.status.idle":"2021-07-05T06:52:24.767245Z","shell.execute_reply.started":"2021-07-05T06:52:24.371948Z","shell.execute_reply":"2021-07-05T06:52:24.766255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_study=studyTrain['integer_label'].values\ny_study = to_categorical(y_study)\ny_study","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:24.768655Z","iopub.execute_input":"2021-07-05T06:52:24.768989Z","iopub.status.idle":"2021-07-05T06:52:24.776607Z","shell.execute_reply.started":"2021-07-05T06:52:24.768954Z","shell.execute_reply":"2021-07-05T06:52:24.775577Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_study.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:24.780212Z","iopub.execute_input":"2021-07-05T06:52:24.780808Z","iopub.status.idle":"2021-07-05T06:52:24.788870Z","shell.execute_reply.started":"2021-07-05T06:52:24.780758Z","shell.execute_reply":"2021-07-05T06:52:24.787564Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(images[10])\ny_study[10]","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:24.791699Z","iopub.execute_input":"2021-07-05T06:52:24.792257Z","iopub.status.idle":"2021-07-05T06:52:24.961847Z","shell.execute_reply.started":"2021-07-05T06:52:24.792212Z","shell.execute_reply":"2021-07-05T06:52:24.960898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### CNN modelling for studyTrain data","metadata":{}},{"cell_type":"code","source":"import keras\nfrom keras import layers\nfrom keras import Sequential\nfrom keras.layers import Dense\n","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:24.963244Z","iopub.execute_input":"2021-07-05T06:52:24.963757Z","iopub.status.idle":"2021-07-05T06:52:24.968448Z","shell.execute_reply.started":"2021-07-05T06:52:24.963718Z","shell.execute_reply":"2021-07-05T06:52:24.967569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(images, y_study, random_state=42, test_size=0.2)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:24.970152Z","iopub.execute_input":"2021-07-05T06:52:24.970726Z","iopub.status.idle":"2021-07-05T06:52:25.250792Z","shell.execute_reply.started":"2021-07-05T06:52:24.970684Z","shell.execute_reply":"2021-07-05T06:52:25.249852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1 = Sequential()\nmodel1.add(Conv2D(32, kernel_size=(3, 3),activation='relu',input_shape=(256,256,3)))\nmodel1.add(Conv2D(64, (3, 3), activation='relu'))\nmodel1.add(MaxPooling2D(pool_size=(2, 2)))\nmodel1.add(Dropout(0.25))\nmodel1.add(Flatten())\nmodel1.add(Dense(128, activation='relu'))\nmodel1.add(Dropout(0.5))\nmodel1.add(Dense(4, activation='softmax'))","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:25.252190Z","iopub.execute_input":"2021-07-05T06:52:25.252578Z","iopub.status.idle":"2021-07-05T06:52:27.538403Z","shell.execute_reply.started":"2021-07-05T06:52:25.252541Z","shell.execute_reply":"2021-07-05T06:52:27.537476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1.summary()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:27.539701Z","iopub.execute_input":"2021-07-05T06:52:27.540057Z","iopub.status.idle":"2021-07-05T06:52:27.552434Z","shell.execute_reply.started":"2021-07-05T06:52:27.540019Z","shell.execute_reply":"2021-07-05T06:52:27.550894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1.compile(loss='categorical_crossentropy',optimizer='Adam',metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:27.553966Z","iopub.execute_input":"2021-07-05T06:52:27.554514Z","iopub.status.idle":"2021-07-05T06:52:27.571298Z","shell.execute_reply.started":"2021-07-05T06:52:27.554472Z","shell.execute_reply":"2021-07-05T06:52:27.570290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1.fit(X_train, y_train, epochs=5, validation_data=(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:52:27.572944Z","iopub.execute_input":"2021-07-05T06:52:27.573489Z","iopub.status.idle":"2021-07-05T06:58:17.773561Z","shell.execute_reply.started":"2021-07-05T06:52:27.573431Z","shell.execute_reply":"2021-07-05T06:58:17.772708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Image Train","metadata":{}},{"cell_type":"code","source":"imageTrain = traindf.drop([\"Unnamed: 0\", \"Negative\", \"Typical\", \"Indeterminate\", \"Atypical\", \"label_y\", \"integer_label\"],axis=1)\nimageTrain","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:17.776512Z","iopub.execute_input":"2021-07-05T06:58:17.776780Z","iopub.status.idle":"2021-07-05T06:58:17.802106Z","shell.execute_reply.started":"2021-07-05T06:58:17.776750Z","shell.execute_reply":"2021-07-05T06:58:17.801314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##### preparing data for modeling","metadata":{}},{"cell_type":"markdown","source":"images=np.array(images)\nimages.shape","metadata":{}},{"cell_type":"code","source":"y_image=imageTrain['integer_Olabel'].values\ny_image = to_categorical(y_image)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:17.803411Z","iopub.execute_input":"2021-07-05T06:58:17.803762Z","iopub.status.idle":"2021-07-05T06:58:17.814069Z","shell.execute_reply.started":"2021-07-05T06:58:17.803725Z","shell.execute_reply":"2021-07-05T06:58:17.813202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_image","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:17.815199Z","iopub.execute_input":"2021-07-05T06:58:17.815567Z","iopub.status.idle":"2021-07-05T06:58:17.825935Z","shell.execute_reply.started":"2021-07-05T06:58:17.815520Z","shell.execute_reply":"2021-07-05T06:58:17.824741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_image.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:17.827407Z","iopub.execute_input":"2021-07-05T06:58:17.828038Z","iopub.status.idle":"2021-07-05T06:58:17.837424Z","shell.execute_reply.started":"2021-07-05T06:58:17.828000Z","shell.execute_reply":"2021-07-05T06:58:17.836516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(images[10])\ny_image[10]","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:17.838794Z","iopub.execute_input":"2021-07-05T06:58:17.839223Z","iopub.status.idle":"2021-07-05T06:58:17.977475Z","shell.execute_reply.started":"2021-07-05T06:58:17.839181Z","shell.execute_reply":"2021-07-05T06:58:17.976689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### CNN modeling for imageTrain data","metadata":{}},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(images, y_image, random_state=42, test_size=0.2)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:17.978796Z","iopub.execute_input":"2021-07-05T06:58:17.979139Z","iopub.status.idle":"2021-07-05T06:58:18.356555Z","shell.execute_reply.started":"2021-07-05T06:58:17.979103Z","shell.execute_reply":"2021-07-05T06:58:18.355668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2 = Sequential()\nmodel2.add(Conv2D(32, kernel_size=(3, 3),activation='relu',input_shape=(256,256,3)))\nmodel2.add(Conv2D(64, (3, 3), activation='relu'))\nmodel2.add(MaxPooling2D(pool_size=(2, 2)))\nmodel2.add(Dropout(0.25))\nmodel2.add(Flatten())\nmodel2.add(Dense(128, activation='relu'))\nmodel2.add(Dropout(0.5))\nmodel2.add(Dense(2, activation='sigmoid'))","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:18.357939Z","iopub.execute_input":"2021-07-05T06:58:18.358326Z","iopub.status.idle":"2021-07-05T06:58:18.409200Z","shell.execute_reply.started":"2021-07-05T06:58:18.358289Z","shell.execute_reply":"2021-07-05T06:58:18.408377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2.summary()","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:18.410476Z","iopub.execute_input":"2021-07-05T06:58:18.410805Z","iopub.status.idle":"2021-07-05T06:58:18.419959Z","shell.execute_reply.started":"2021-07-05T06:58:18.410770Z","shell.execute_reply":"2021-07-05T06:58:18.418891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2.compile(loss = 'binary_crossentropy',optimizer='Adam',metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:18.421485Z","iopub.execute_input":"2021-07-05T06:58:18.421918Z","iopub.status.idle":"2021-07-05T06:58:18.434268Z","shell.execute_reply.started":"2021-07-05T06:58:18.421879Z","shell.execute_reply":"2021-07-05T06:58:18.433528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2.fit(X_train, y_train, epochs=5, validation_data=(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2021-07-05T06:58:18.435735Z","iopub.execute_input":"2021-07-05T06:58:18.436370Z","iopub.status.idle":"2021-07-05T07:03:59.620924Z","shell.execute_reply.started":"2021-07-05T06:58:18.436332Z","shell.execute_reply":"2021-07-05T07:03:59.620149Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### reading test data","metadata":{}},{"cell_type":"code","source":"testdf = pd.read_csv('../input/testdataset/test.csv')\ntestdf","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:03:59.625124Z","iopub.execute_input":"2021-07-05T07:03:59.625398Z","iopub.status.idle":"2021-07-05T07:03:59.657839Z","shell.execute_reply.started":"2021-07-05T07:03:59.625371Z","shell.execute_reply":"2021-07-05T07:03:59.657063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testdf.drop([\"Unnamed: 0\"], axis = 1)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:03:59.659795Z","iopub.execute_input":"2021-07-05T07:03:59.660144Z","iopub.status.idle":"2021-07-05T07:03:59.673365Z","shell.execute_reply.started":"2021-07-05T07:03:59.660107Z","shell.execute_reply":"2021-07-05T07:03:59.672191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### reading test images","metadata":{}},{"cell_type":"code","source":"pathtest = \"../input/siim-covid19-resized-to-256px-jpg/test\"\nimgs=os.listdir(pathtest)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:03:59.675017Z","iopub.execute_input":"2021-07-05T07:03:59.675506Z","iopub.status.idle":"2021-07-05T07:03:59.957960Z","shell.execute_reply.started":"2021-07-05T07:03:59.675469Z","shell.execute_reply":"2021-07-05T07:03:59.957080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testimages = []\nfor i in range(testdf.shape[0]):\n    kk = testdf[i:i+1]\n    #print(kk)\n    img = kk['image']\n    img = img[i]\n    imgf = img + '.jpg'\n    imgfile = os.path.join(pathtest,imgf)\n    #print(imgfile)\n    imgg = cv2.imread(imgfile)\n    testimages.append(imgg)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:03:59.961072Z","iopub.execute_input":"2021-07-05T07:03:59.961367Z","iopub.status.idle":"2021-07-05T07:04:08.357730Z","shell.execute_reply.started":"2021-07-05T07:03:59.961341Z","shell.execute_reply":"2021-07-05T07:04:08.356847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Predictions on study level","metadata":{}},{"cell_type":"code","source":"testStudy=np.array(testimages)\ntestStudy.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:08.358997Z","iopub.execute_input":"2021-07-05T07:04:08.359366Z","iopub.status.idle":"2021-07-05T07:04:08.487616Z","shell.execute_reply.started":"2021-07-05T07:04:08.359328Z","shell.execute_reply":"2021-07-05T07:04:08.486617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model1.predict_classes(testStudy)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:08.489005Z","iopub.execute_input":"2021-07-05T07:04:08.489382Z","iopub.status.idle":"2021-07-05T07:04:21.323934Z","shell.execute_reply.started":"2021-07-05T07:04:08.489346Z","shell.execute_reply":"2021-07-05T07:04:21.323049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleStudy = pd.read_csv('../input/samplesubmissions/Studysubmission.csv')\nsampleStudy","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.325363Z","iopub.execute_input":"2021-07-05T07:04:21.325708Z","iopub.status.idle":"2021-07-05T07:04:21.359004Z","shell.execute_reply.started":"2021-07-05T07:04:21.325673Z","shell.execute_reply":"2021-07-05T07:04:21.358130Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleStudy = sampleStudy.drop([\"Unnamed: 0\"], axis = 1)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.360158Z","iopub.execute_input":"2021-07-05T07:04:21.360505Z","iopub.status.idle":"2021-07-05T07:04:21.367245Z","shell.execute_reply.started":"2021-07-05T07:04:21.360478Z","shell.execute_reply":"2021-07-05T07:04:21.364505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleStudy['label'] = prediction","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.368575Z","iopub.execute_input":"2021-07-05T07:04:21.369128Z","iopub.status.idle":"2021-07-05T07:04:21.376461Z","shell.execute_reply.started":"2021-07-05T07:04:21.369081Z","shell.execute_reply":"2021-07-05T07:04:21.375656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleStudy","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.377705Z","iopub.execute_input":"2021-07-05T07:04:21.378056Z","iopub.status.idle":"2021-07-05T07:04:21.395862Z","shell.execute_reply.started":"2021-07-05T07:04:21.378020Z","shell.execute_reply":"2021-07-05T07:04:21.394941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleStudy.loc[sampleStudy['label']==3, 'PredictionString'] = 'typical 1 0 0 1 1'\nsampleStudy.loc[sampleStudy['label']==0, 'PredictionString'] = 'atypical 1 0 0 1 1'\nsampleStudy.loc[sampleStudy['label']==1, 'PredictionString'] = 'indeterminate 1 0 0 1 1'","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.396991Z","iopub.execute_input":"2021-07-05T07:04:21.397392Z","iopub.status.idle":"2021-07-05T07:04:21.423008Z","shell.execute_reply.started":"2021-07-05T07:04:21.397357Z","shell.execute_reply":"2021-07-05T07:04:21.422240Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleStudy","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.425607Z","iopub.execute_input":"2021-07-05T07:04:21.425854Z","iopub.status.idle":"2021-07-05T07:04:21.439645Z","shell.execute_reply.started":"2021-07-05T07:04:21.425826Z","shell.execute_reply":"2021-07-05T07:04:21.438726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleStudy = sampleStudy.drop([\"id_image\", \"label\"], axis = 1)\nsampleStudy","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.441206Z","iopub.execute_input":"2021-07-05T07:04:21.441743Z","iopub.status.idle":"2021-07-05T07:04:21.454614Z","shell.execute_reply.started":"2021-07-05T07:04:21.441708Z","shell.execute_reply":"2021-07-05T07:04:21.453676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Predictions on image level","metadata":{}},{"cell_type":"code","source":"testImage=np.array(testimages)\ntestImage.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.455890Z","iopub.execute_input":"2021-07-05T07:04:21.456328Z","iopub.status.idle":"2021-07-05T07:04:21.547573Z","shell.execute_reply.started":"2021-07-05T07:04:21.456294Z","shell.execute_reply":"2021-07-05T07:04:21.546752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model2.predict_classes(testImage)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:21.548721Z","iopub.execute_input":"2021-07-05T07:04:21.549050Z","iopub.status.idle":"2021-07-05T07:04:33.444671Z","shell.execute_reply.started":"2021-07-05T07:04:21.549015Z","shell.execute_reply":"2021-07-05T07:04:33.443752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleImage = pd.read_csv('../input/samplesubmissions/Imagesubmission.csv')\nsampleImage","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:33.445888Z","iopub.execute_input":"2021-07-05T07:04:33.446360Z","iopub.status.idle":"2021-07-05T07:04:33.479713Z","shell.execute_reply.started":"2021-07-05T07:04:33.446323Z","shell.execute_reply":"2021-07-05T07:04:33.478971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleImage = sampleImage.drop([\"Unnamed: 0\"], axis = 1)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:33.483233Z","iopub.execute_input":"2021-07-05T07:04:33.485183Z","iopub.status.idle":"2021-07-05T07:04:33.491495Z","shell.execute_reply.started":"2021-07-05T07:04:33.485130Z","shell.execute_reply":"2021-07-05T07:04:33.490554Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleImage['label'] = prediction\nsampleImage","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:33.495341Z","iopub.execute_input":"2021-07-05T07:04:33.497540Z","iopub.status.idle":"2021-07-05T07:04:33.516091Z","shell.execute_reply.started":"2021-07-05T07:04:33.497501Z","shell.execute_reply":"2021-07-05T07:04:33.515355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleImage.loc[sampleImage['label']==1, 'PredictionString'] = 'opacity 1 0 0 1 1'","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:33.519584Z","iopub.execute_input":"2021-07-05T07:04:33.521520Z","iopub.status.idle":"2021-07-05T07:04:33.528379Z","shell.execute_reply.started":"2021-07-05T07:04:33.521480Z","shell.execute_reply":"2021-07-05T07:04:33.527644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleImage = sampleImage.drop([\"label\"], axis = 1)\nsampleImage","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:33.532327Z","iopub.execute_input":"2021-07-05T07:04:33.534554Z","iopub.status.idle":"2021-07-05T07:04:33.552181Z","shell.execute_reply.started":"2021-07-05T07:04:33.534517Z","shell.execute_reply":"2021-07-05T07:04:33.551448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Creating the submission file","metadata":{}},{"cell_type":"code","source":"submission = pd.concat([sampleStudy, sampleImage], sort = False, ignore_index = True)\nsubmission","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:33.555736Z","iopub.execute_input":"2021-07-05T07:04:33.557642Z","iopub.status.idle":"2021-07-05T07:04:33.575654Z","shell.execute_reply.started":"2021-07-05T07:04:33.557603Z","shell.execute_reply":"2021-07-05T07:04:33.574874Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('./submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2021-07-05T07:04:46.114139Z","iopub.execute_input":"2021-07-05T07:04:46.114480Z","iopub.status.idle":"2021-07-05T07:04:46.128776Z","shell.execute_reply.started":"2021-07-05T07:04:46.114449Z","shell.execute_reply":"2021-07-05T07:04:46.127890Z"},"trusted":true},"execution_count":null,"outputs":[]}]}