{"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 tensorflow as tf\nimport os\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom PIL import Image, ImageDraw, ImageEnhance","metadata":{"id":"S_tiHTxZ9fF-","execution":{"iopub.status.busy":"2022-03-16T14:40:55.683818Z","iopub.execute_input":"2022-03-16T14:40:55.684589Z","iopub.status.idle":"2022-03-16T14:41:00.244355Z","shell.execute_reply.started":"2022-03-16T14:40:55.684497Z","shell.execute_reply":"2022-03-16T14:41:00.243330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"directory = '../input/state-farm-distracted-driver-detection/imgs/train'\ntest_directory = '../input/state-farm-distracted-driver-detection/imgs/test'\nrandom_test = '../input/driver/'\nclasses = ['c0','c1','c2','c3','c4','c5','c6','c7','c8','c9']","metadata":{"id":"AuhcZqU49h3X","execution":{"iopub.status.busy":"2022-03-16T14:41:00.246146Z","iopub.execute_input":"2022-03-16T14:41:00.246415Z","iopub.status.idle":"2022-03-16T14:41:00.251814Z","shell.execute_reply.started":"2022-03-16T14:41:00.246382Z","shell.execute_reply":"2022-03-16T14:41:00.250744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img_size1 = 240\nimg_size2 = 240","metadata":{"id":"TahxF0d79h0e","execution":{"iopub.status.busy":"2022-03-16T14:41:00.253334Z","iopub.execute_input":"2022-03-16T14:41:00.253974Z","iopub.status.idle":"2022-03-16T14:41:00.262129Z","shell.execute_reply.started":"2022-03-16T14:41:00.253922Z","shell.execute_reply":"2022-03-16T14:41:00.261171Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_data = []\ni = 0\ndef create_training_data():\n    for category in classes:\n        path = os.path.join(directory,category)\n        class_num = classes.index(category)\n        \n        for img in os.listdir(path):\n            img_array = cv2.imread(os.path.join(path,img),cv2.IMREAD_GRAYSCALE)\n            new_img = cv2.resize(img_array,(img_size2,img_size1))\n            training_data.append([\n                new_img,class_num])\n","metadata":{"id":"JumNT9x69hxq","execution":{"iopub.status.busy":"2022-03-16T14:41:00.265059Z","iopub.execute_input":"2022-03-16T14:41:00.265366Z","iopub.status.idle":"2022-03-16T14:41:00.273304Z","shell.execute_reply.started":"2022-03-16T14:41:00.265329Z","shell.execute_reply":"2022-03-16T14:41:00.272679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testing_data = []\ni = 0\ndef create_testing_data():        \n    for img in os.listdir(test_directory):\n        img_array = cv2.imread(os.path.join(test_directory,img),cv2.IMREAD_GRAYSCALE)\n        new_img = cv2.resize(img_array,(img_size2,img_size1))\n        testing_data.append([img,\n            new_img])","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:41:00.275192Z","iopub.execute_input":"2022-03-16T14:41:00.275742Z","iopub.status.idle":"2022-03-16T14:41:00.283056Z","shell.execute_reply.started":"2022-03-16T14:41:00.275706Z","shell.execute_reply":"2022-03-16T14:41:00.282099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:41:00.284414Z","iopub.execute_input":"2022-03-16T14:41:00.285423Z","iopub.status.idle":"2022-03-16T14:41:00.448128Z","shell.execute_reply.started":"2022-03-16T14:41:00.285393Z","shell.execute_reply":"2022-03-16T14:41:00.447387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"create_training_data()","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:41:00.450264Z","iopub.execute_input":"2022-03-16T14:41:00.450998Z","iopub.status.idle":"2022-03-16T14:43:57.597318Z","shell.execute_reply.started":"2022-03-16T14:41:00.450961Z","shell.execute_reply":"2022-03-16T14:43:57.596530Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"create_testing_data()","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:43:57.600367Z","iopub.execute_input":"2022-03-16T14:43:57.600963Z","iopub.status.idle":"2022-03-16T14:56:47.145875Z","shell.execute_reply.started":"2022-03-16T14:43:57.600933Z","shell.execute_reply":"2022-03-16T14:56:47.145142Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import random","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:47.149017Z","iopub.execute_input":"2022-03-16T14:56:47.149219Z","iopub.status.idle":"2022-03-16T14:56:47.154706Z","shell.execute_reply.started":"2022-03-16T14:56:47.149196Z","shell.execute_reply":"2022-03-16T14:56:47.153963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"random.shuffle(training_data)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:47.158623Z","iopub.execute_input":"2022-03-16T14:56:47.158981Z","iopub.status.idle":"2022-03-16T14:56:47.186928Z","shell.execute_reply.started":"2022-03-16T14:56:47.158952Z","shell.execute_reply":"2022-03-16T14:56:47.186259Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = []\ny = []","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:47.188139Z","iopub.execute_input":"2022-03-16T14:56:47.189037Z","iopub.status.idle":"2022-03-16T14:56:47.197182Z","shell.execute_reply.started":"2022-03-16T14:56:47.188999Z","shell.execute_reply":"2022-03-16T14:56:47.196449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for features, label in training_data:\n    x.append(features)\n    y.append(label)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:47.198573Z","iopub.execute_input":"2022-03-16T14:56:47.198863Z","iopub.status.idle":"2022-03-16T14:56:47.217282Z","shell.execute_reply.started":"2022-03-16T14:56:47.198828Z","shell.execute_reply":"2022-03-16T14:56:47.216551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nX = np.array(x).reshape(-1,img_size2,img_size1,1)\nx_train,x_test,y_train,y_test = train_test_split(X,y,test_size=0.3,random_state=50)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:47.218683Z","iopub.execute_input":"2022-03-16T14:56:47.219031Z","iopub.status.idle":"2022-03-16T14:56:50.412359Z","shell.execute_reply.started":"2022-03-16T14:56:47.218996Z","shell.execute_reply":"2022-03-16T14:56:50.411607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y_train = tf.keras.utils.to_categorical(y_train,num_classes=10)\nY_test = tf.keras.utils.to_categorical(y_test,num_classes=10)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:50.413819Z","iopub.execute_input":"2022-03-16T14:56:50.414070Z","iopub.status.idle":"2022-03-16T14:56:50.424052Z","shell.execute_reply.started":"2022-03-16T14:56:50.414037Z","shell.execute_reply":"2022-03-16T14:56:50.423197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = tf.keras.Sequential()\nmodel.add(tf.keras.layers.Conv2D(32,kernel_size=(3,3),activation='relu',input_shape=(240,240,1)))\nmodel.add(tf.keras.layers.BatchNormalization())\nmodel.add(tf.keras.layers.Conv2D(32,kernel_size=(3,3),activation='relu',padding='same'))\nmodel.add(tf.keras.layers.BatchNormalization(axis = 3))\nmodel.add(tf.keras.layers.MaxPooling2D(pool_size=(2,2),padding='same'))\nmodel.add(tf.keras.layers.Dropout(0.3))\nmodel.add(tf.keras.layers.Conv2D(64,kernel_size=(3,3),activation='relu',padding='same'))\nmodel.add(tf.keras.layers.BatchNormalization())\nmodel.add(tf.keras.layers.Conv2D(64,kernel_size=(3,3),activation='relu',padding='same'))\nmodel.add(tf.keras.layers.BatchNormalization(axis = 3))\nmodel.add(tf.keras.layers.MaxPooling2D(pool_size=(2,2),padding='same'))\nmodel.add(tf.keras.layers.Dropout(0.3))\nmodel.add(tf.keras.layers.Conv2D(128,kernel_size=(3,3),activation='relu',padding='same'))\nmodel.add(tf.keras.layers.BatchNormalization())\nmodel.add(tf.keras.layers.Conv2D(128,kernel_size=(3,3),activation='relu',padding='same'))\nmodel.add(tf.keras.layers.BatchNormalization(axis = 3))\nmodel.add(tf.keras.layers.MaxPooling2D(pool_size=(2,2),padding='same'))\nmodel.add(tf.keras.layers.Dropout(0.5))\nmodel.add(tf.keras.layers.Flatten())\nmodel.add(tf.keras.layers.Dense(units = 512,activation='relu'))\nmodel.add(tf.keras.layers.BatchNormalization())\nmodel.add(tf.keras.layers.Dropout(0.5))\nmodel.add(tf.keras.layers.Dense(units = 128,activation='relu'))\nmodel.add(tf.keras.layers.Dropout(0.25))\nmodel.add(tf.keras.layers.Dense(10,activation='softmax'))","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:50.425547Z","iopub.execute_input":"2022-03-16T14:56:50.425860Z","iopub.status.idle":"2022-03-16T14:56:52.629261Z","shell.execute_reply.started":"2022-03-16T14:56:50.425823Z","shell.execute_reply":"2022-03-16T14:56:52.628580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(loss='categorical_crossentropy',metrics=['accuracy'],optimizer='adam')","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:52.630525Z","iopub.execute_input":"2022-03-16T14:56:52.630912Z","iopub.status.idle":"2022-03-16T14:56:52.645784Z","shell.execute_reply.started":"2022-03-16T14:56:52.630880Z","shell.execute_reply":"2022-03-16T14:56:52.645040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"callbacks = [tf.keras.callbacks.EarlyStopping(monitor='val_acc',patience=5)]","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:52.647116Z","iopub.execute_input":"2022-03-16T14:56:52.647397Z","iopub.status.idle":"2022-03-16T14:56:52.653715Z","shell.execute_reply.started":"2022-03-16T14:56:52.647362Z","shell.execute_reply":"2022-03-16T14:56:52.652964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"batch_size = 50\nn_epochs = 10","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:52.655000Z","iopub.execute_input":"2022-03-16T14:56:52.655878Z","iopub.status.idle":"2022-03-16T14:56:52.661599Z","shell.execute_reply.started":"2022-03-16T14:56:52.655841Z","shell.execute_reply":"2022-03-16T14:56:52.660897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"results = model.fit(x_train,Y_train,batch_size=batch_size,epochs=n_epochs,verbose=1,validation_data=(x_test,Y_test),callbacks=callbacks)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T14:56:52.663003Z","iopub.execute_input":"2022-03-16T14:56:52.663271Z","iopub.status.idle":"2022-03-16T15:05:48.854041Z","shell.execute_reply.started":"2022-03-16T14:56:52.663238Z","shell.execute_reply":"2022-03-16T15:05:48.853275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(results.history['accuracy'])\nplt.plot(results.history['val_accuracy'])\nplt.title('Model accuracy')\nplt.ylabel('Accuracy')\nplt.xlabel('Epoch')\nplt.legend(['Train', 'Test'], loc='upper left')\nplt.show()\n\n# Plot training & validation loss values\nplt.plot(results.history['loss'])\nplt.plot(results.history['val_loss'])\nplt.title('Model loss')\nplt.ylabel('Loss')\nplt.xlabel('Epoch')\nplt.legend(['Train', 'Test'], loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:06:10.082853Z","iopub.execute_input":"2022-03-16T15:06:10.083503Z","iopub.status.idle":"2022-03-16T15:06:10.514064Z","shell.execute_reply.started":"2022-03-16T15:06:10.083454Z","shell.execute_reply":"2022-03-16T15:06:10.513390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = model.predict(np.array(testing_data[0][1]).reshape(-1,img_size2,img_size1,1))","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:07:00.396829Z","iopub.execute_input":"2022-03-16T15:07:00.397462Z","iopub.status.idle":"2022-03-16T15:07:00.672921Z","shell.execute_reply.started":"2022-03-16T15:07:00.397424Z","shell.execute_reply":"2022-03-16T15:07:00.672198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save_weights('./driverdistraction_lr_weights.h5', overwrite=True)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:07:06.863233Z","iopub.execute_input":"2022-03-16T15:07:06.863501Z","iopub.status.idle":"2022-03-16T15:07:07.700444Z","shell.execute_reply.started":"2022-03-16T15:07:06.863474Z","shell.execute_reply":"2022-03-16T15:07:07.699725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save('./driverdistraction_lr_weights.h5')","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:07:46.756073Z","iopub.execute_input":"2022-03-16T15:07:46.756328Z","iopub.status.idle":"2022-03-16T15:07:49.366973Z","shell.execute_reply.started":"2022-03-16T15:07:46.756301Z","shell.execute_reply":"2022-03-16T15:07:49.366223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"loaded_model = tf.keras.models.load_model('./driverdistraction_lr_weights.h5')","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:09:11.809100Z","iopub.execute_input":"2022-03-16T15:09:11.809536Z","iopub.status.idle":"2022-03-16T15:09:14.854536Z","shell.execute_reply.started":"2022-03-16T15:09:11.809502Z","shell.execute_reply":"2022-03-16T15:09:14.850689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data = np.array(testing_data[3000][1]).reshape(-1,img_size2,img_size1,1)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:10:04.882131Z","iopub.execute_input":"2022-03-16T15:10:04.882396Z","iopub.status.idle":"2022-03-16T15:10:04.887254Z","shell.execute_reply.started":"2022-03-16T15:10:04.882369Z","shell.execute_reply":"2022-03-16T15:10:04.886167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = loaded_model.predict(test_data)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:10:10.019509Z","iopub.execute_input":"2022-03-16T15:10:10.019941Z","iopub.status.idle":"2022-03-16T15:10:10.500005Z","shell.execute_reply.started":"2022-03-16T15:10:10.019900Z","shell.execute_reply":"2022-03-16T15:10:10.499245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Predicted: {}'.format(np.argmax(preds)))","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:10:13.051223Z","iopub.execute_input":"2022-03-16T15:10:13.051494Z","iopub.status.idle":"2022-03-16T15:10:13.057321Z","shell.execute_reply.started":"2022-03-16T15:10:13.051466Z","shell.execute_reply":"2022-03-16T15:10:13.056560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testing_data[1]","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:11:16.485092Z","iopub.execute_input":"2022-03-16T15:11:16.485364Z","iopub.status.idle":"2022-03-16T15:11:16.493810Z","shell.execute_reply.started":"2022-03-16T15:11:16.485336Z","shell.execute_reply":"2022-03-16T15:11:16.493123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission=None\nsubmission=pd.DataFrame(columns=['img','c0','c1','c2','c3','c4','c5','c6','c7','c8','c9'])","metadata":{"execution":{"iopub.status.busy":"2022-03-16T17:46:35.855694Z","iopub.execute_input":"2022-03-16T17:46:35.856370Z","iopub.status.idle":"2022-03-16T17:46:35.862888Z","shell.execute_reply.started":"2022-03-16T17:46:35.856334Z","shell.execute_reply":"2022-03-16T17:46:35.862163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv('../input/state-farm-distracted-driver-detection/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:15:54.321499Z","iopub.execute_input":"2022-03-16T15:15:54.321766Z","iopub.status.idle":"2022-03-16T15:15:54.486217Z","shell.execute_reply.started":"2022-03-16T15:15:54.321739Z","shell.execute_reply":"2022-03-16T15:15:54.485534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[:10000]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission\n    ","metadata":{"execution":{"iopub.status.busy":"2022-03-16T17:46:39.369345Z","iopub.execute_input":"2022-03-16T17:46:39.369898Z","iopub.status.idle":"2022-03-16T17:53:10.965233Z","shell.execute_reply.started":"2022-03-16T17:46:39.369860Z","shell.execute_reply":"2022-03-16T17:53:10.964541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('./submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-03-16T15:40:03.161786Z","iopub.execute_input":"2022-03-16T15:40:03.162345Z","iopub.status.idle":"2022-03-16T15:40:03.223202Z","shell.execute_reply.started":"2022-03-16T15:40:03.162313Z","shell.execute_reply":"2022-03-16T15:40:03.222483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[10000:20000]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-03-16T17:53:15.428126Z","iopub.execute_input":"2022-03-16T17:53:15.428393Z","iopub.status.idle":"2022-03-16T18:00:13.147363Z","shell.execute_reply.started":"2022-03-16T17:53:15.428365Z","shell.execute_reply":"2022-03-16T18:00:13.146578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[20000:30000]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-03-16T18:00:28.279811Z","iopub.execute_input":"2022-03-16T18:00:28.280354Z","iopub.status.idle":"2022-03-16T18:07:54.465368Z","shell.execute_reply.started":"2022-03-16T18:00:28.280315Z","shell.execute_reply":"2022-03-16T18:07:54.464544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[30000:40000]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-03-16T18:08:06.628409Z","iopub.execute_input":"2022-03-16T18:08:06.628711Z","iopub.status.idle":"2022-03-16T18:15:52.147108Z","shell.execute_reply.started":"2022-03-16T18:08:06.628682Z","shell.execute_reply":"2022-03-16T18:15:52.146193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[40000:50000]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-03-16T18:16:04.471264Z","iopub.execute_input":"2022-03-16T18:16:04.471973Z","iopub.status.idle":"2022-03-16T18:24:06.656582Z","shell.execute_reply.started":"2022-03-16T18:16:04.471939Z","shell.execute_reply":"2022-03-16T18:24:06.655873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[50000:60000]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-03-16T18:24:22.577300Z","iopub.execute_input":"2022-03-16T18:24:22.577804Z","iopub.status.idle":"2022-03-16T18:32:57.168750Z","shell.execute_reply.started":"2022-03-16T18:24:22.577765Z","shell.execute_reply":"2022-03-16T18:32:57.168008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[60000:70000]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-03-16T18:34:11.828825Z","iopub.execute_input":"2022-03-16T18:34:11.829267Z","iopub.status.idle":"2022-03-16T18:42:54.857710Z","shell.execute_reply.started":"2022-03-16T18:34:11.829222Z","shell.execute_reply":"2022-03-16T18:42:54.856964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for  n,i in testing_data[70000:]:\n    pred=model.predict(i.reshape(-1,img_size2,img_size1,1))\n    one=(np.argmax(pred))\n    row=[n,0,0,0,0,0,0,0,0,0,0]\n    row[one+1]=1\n    submission.loc[len(submission.index)] = row\n\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-03-16T18:43:04.945531Z","iopub.execute_input":"2022-03-16T18:43:04.946156Z","iopub.status.idle":"2022-03-16T18:51:53.399387Z","shell.execute_reply.started":"2022-03-16T18:43:04.946117Z","shell.execute_reply":"2022-03-16T18:51:53.398585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.sort_values(by=['img']).to_csv('final2.csv',index=False)","metadata":{"execution":{"iopub.status.busy":"2022-03-16T19:11:01.641393Z","iopub.execute_input":"2022-03-16T19:11:01.641947Z","iopub.status.idle":"2022-03-16T19:11:02.091478Z","shell.execute_reply.started":"2022-03-16T19:11:01.641912Z","shell.execute_reply":"2022-03-16T19:11:02.090732Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}