{"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":"# 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-09-28T05:04:40.336918Z","iopub.execute_input":"2023-09-28T05:04:40.337305Z","iopub.status.idle":"2023-09-28T05:04:54.788182Z","shell.execute_reply.started":"2023-09-28T05:04:40.337271Z","shell.execute_reply":"2023-09-28T05:04:54.787237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport tensorflow as tf\nimport cv2","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:04:54.789623Z","iopub.execute_input":"2023-09-28T05:04:54.790574Z","iopub.status.idle":"2023-09-28T05:05:11.646611Z","shell.execute_reply.started":"2023-09-28T05:04:54.790535Z","shell.execute_reply":"2023-09-28T05:05:11.645601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_json(\"/kaggle/input/cassava-leaf-disease-classification/label_num_to_disease_map.json\",orient='index',)\ndata = data._rename(columns={0:\"disease\"})\ndata","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:11.647979Z","iopub.execute_input":"2023-09-28T05:05:11.648741Z","iopub.status.idle":"2023-09-28T05:05:11.685601Z","shell.execute_reply.started":"2023-09-28T05:05:11.648704Z","shell.execute_reply":"2023-09-28T05:05:11.684747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/cassava-leaf-disease-classification/train.csv')\ndf.sample(5)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:11.688796Z","iopub.execute_input":"2023-09-28T05:05:11.689216Z","iopub.status.idle":"2023-09-28T05:05:11.727115Z","shell.execute_reply.started":"2023-09-28T05:05:11.689183Z","shell.execute_reply":"2023-09-28T05:05:11.726006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.label.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:11.728511Z","iopub.execute_input":"2023-09-28T05:05:11.728984Z","iopub.status.idle":"2023-09-28T05:05:11.744751Z","shell.execute_reply.started":"2023-09-28T05:05:11.728946Z","shell.execute_reply":"2023-09-28T05:05:11.743692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.label.count()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:11.745951Z","iopub.execute_input":"2023-09-28T05:05:11.746337Z","iopub.status.idle":"2023-09-28T05:05:11.755260Z","shell.execute_reply.started":"2023-09-28T05:05:11.746306Z","shell.execute_reply":"2023-09-28T05:05:11.754175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cw ={0:(1/1087*(21397/5)),\n     1:(1/2189*(21397/5)),\n     2:(1/2386*(21397/5)),\n     3:(1/13158*(21397/5)),\n     4:(1/2577*(21397/5))\n         }\ncw","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:11.756908Z","iopub.execute_input":"2023-09-28T05:05:11.757225Z","iopub.status.idle":"2023-09-28T05:05:11.769620Z","shell.execute_reply.started":"2023-09-28T05:05:11.757196Z","shell.execute_reply":"2023-09-28T05:05:11.768162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.label=df.label.astype('string')\ndf.info()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:11.770766Z","iopub.execute_input":"2023-09-28T05:05:11.771017Z","iopub.status.idle":"2023-09-28T05:05:11.815887Z","shell.execute_reply.started":"2023-09-28T05:05:11.770995Z","shell.execute_reply":"2023-09-28T05:05:11.814907Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = tf.keras.preprocessing.image.load_img('/kaggle/input/cassava-leaf-disease-classification/train_images/1483502855.jpg')\nimg","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:11.817093Z","iopub.execute_input":"2023-09-28T05:05:11.817403Z","iopub.status.idle":"2023-09-28T05:05:12.037614Z","shell.execute_reply.started":"2023-09-28T05:05:11.817374Z","shell.execute_reply":"2023-09-28T05:05:12.036857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.keras.preprocessing.image.img_to_array(img).shape","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:12.041787Z","iopub.execute_input":"2023-09-28T05:05:12.042883Z","iopub.status.idle":"2023-09-28T05:05:12.053278Z","shell.execute_reply.started":"2023-09-28T05:05:12.042848Z","shell.execute_reply":"2023-09-28T05:05:12.051968Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"idg = tf.keras.preprocessing.image.ImageDataGenerator(rotation_range=20,brightness_range=(0.8,1.2),\n                                                      width_shift_range=0.2,height_shift_range=0.2,\n                                                     horizontal_flip=True,zoom_range=(0.8,1.2),\n                                                      validation_split=0.1)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:12.054829Z","iopub.execute_input":"2023-09-28T05:05:12.055453Z","iopub.status.idle":"2023-09-28T05:05:12.061284Z","shell.execute_reply.started":"2023-09-28T05:05:12.055422Z","shell.execute_reply":"2023-09-28T05:05:12.060439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"batch_size=32","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:12.063107Z","iopub.execute_input":"2023-09-28T05:05:12.063761Z","iopub.status.idle":"2023-09-28T05:05:12.082924Z","shell.execute_reply.started":"2023-09-28T05:05:12.063708Z","shell.execute_reply":"2023-09-28T05:05:12.081718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_idg = idg.flow_from_dataframe(df,'/kaggle/input/cassava-leaf-disease-classification/train_images','image_id','label',\n                                   target_size=(300, 400), batch_size=batch_size,\n                                   subset='training')","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:12.084934Z","iopub.execute_input":"2023-09-28T05:05:12.085646Z","iopub.status.idle":"2023-09-28T05:05:36.974048Z","shell.execute_reply.started":"2023-09-28T05:05:12.085594Z","shell.execute_reply":"2023-09-28T05:05:36.973021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_idg = idg.flow_from_dataframe(df,'/kaggle/input/cassava-leaf-disease-classification/train_images','image_id','label',\n                                   target_size=(300,400), batch_size=batch_size,\n                                   subset='validation')","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:05:36.975679Z","iopub.execute_input":"2023-09-28T05:05:36.976255Z","iopub.status.idle":"2023-09-28T05:06:00.603374Z","shell.execute_reply.started":"2023-09-28T05:05:36.976208Z","shell.execute_reply":"2023-09-28T05:06:00.602480Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"input = tf.keras.layers.Input((300, 400, 3),name='Input_layer')\n\nres_preprocess = tf.keras.layers.Lambda(tf.keras.applications.resnet_v2.preprocess_input,output_shape=(300, 400, 3),name=\"ResNet152V2_Preprocess\") (input)\nresnet_model = tf.keras.applications.ResNet152V2(include_top=False,input_shape=(300, 400, 3))\nresnet_model.trainable = False\nresnet = resnet_model (res_preprocess)\nres_gap = tf.keras.layers.GlobalAveragePooling2D(name='Res_GAP') (resnet)\n\nmob_preprocess = tf.keras.layers.Lambda(tf.keras.applications.mobilenet_v3.preprocess_input,output_shape=(300,400, 3),name=\"MobileNet_Preprocess\") (input)\nmobile_model = tf.keras.applications.MobileNetV3Large(include_top=False,input_shape=(300, 400, 3))\nmobile_model.trainable = False\nmobile = mobile_model (mob_preprocess)\nmob_gap = tf.keras.layers.GlobalAveragePooling2D(name='Mob_GAP') (mobile)\n\nvgg_preprocess = tf.keras.layers.Lambda(tf.keras.applications.vgg16.preprocess_input,output_shape=(300,400, 3),name=\"VGG16_Preprocess\") (input)\nvgg_model = tf.keras.applications.vgg16.VGG16(include_top=False, input_shape=(300,400,3))\nvgg_model.trainable = False\nvgg = vgg_model (vgg_preprocess)\ngap_vgg = tf.keras.layers.GlobalAveragePooling2D(name='GAP_vgg') (vgg)\n\nconcat = tf.keras.layers.Concatenate(name='Concat') ([res_gap,mob_gap,gap_vgg])\ndrop = tf.keras.layers.Dropout(0.1) (concat)\n\ndense1 = tf.keras.layers.Dense(512,activation='relu',name='Hidden1') (drop)\ndense2 = tf.keras.layers.Dense(64,activation='relu',name='Hidden2') (dense1)\noutput = tf.keras.layers.Dense(5,activation='softmax',name='Output_layer') (dense2)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:00.605012Z","iopub.execute_input":"2023-09-28T05:06:00.605386Z","iopub.status.idle":"2023-09-28T05:06:18.667890Z","shell.execute_reply.started":"2023-09-28T05:06:00.605353Z","shell.execute_reply":"2023-09-28T05:06:18.666815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# del model","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:18.669273Z","iopub.execute_input":"2023-09-28T05:06:18.669655Z","iopub.status.idle":"2023-09-28T05:06:18.676584Z","shell.execute_reply.started":"2023-09-28T05:06:18.669600Z","shell.execute_reply":"2023-09-28T05:06:18.675570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = tf.keras.models.Model(inputs=input, outputs=output)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:18.678132Z","iopub.execute_input":"2023-09-28T05:06:18.678684Z","iopub.status.idle":"2023-09-28T05:06:18.692177Z","shell.execute_reply.started":"2023-09-28T05:06:18.678623Z","shell.execute_reply":"2023-09-28T05:06:18.691280Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.002),\n             loss=tf.keras.losses.categorical_crossentropy,\n             metrics=['acc'])","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:18.693478Z","iopub.execute_input":"2023-09-28T05:06:18.693834Z","iopub.status.idle":"2023-09-28T05:06:18.731308Z","shell.execute_reply.started":"2023-09-28T05:06:18.693802Z","shell.execute_reply":"2023-09-28T05:06:18.730420Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.keras.utils.plot_model(model,show_shapes=True)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:18.732476Z","iopub.execute_input":"2023-09-28T05:06:18.732888Z","iopub.status.idle":"2023-09-28T05:06:19.274505Z","shell.execute_reply.started":"2023-09-28T05:06:18.732855Z","shell.execute_reply":"2023-09-28T05:06:19.273650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:19.275988Z","iopub.execute_input":"2023-09-28T05:06:19.276582Z","iopub.status.idle":"2023-09-28T05:06:19.386599Z","shell.execute_reply.started":"2023-09-28T05:06:19.276545Z","shell.execute_reply":"2023-09-28T05:06:19.385686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf_call = tf.keras.callbacks.ModelCheckpoint('Model_checkpoint',save_best_only=True)\ntf_es = tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience = 3)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:19.387904Z","iopub.execute_input":"2023-09-28T05:06:19.388704Z","iopub.status.idle":"2023-09-28T05:06:19.394387Z","shell.execute_reply.started":"2023-09-28T05:06:19.388667Z","shell.execute_reply":"2023-09-28T05:06:19.393381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(train_idg, batch_size=batch_size, epochs=13,validation_data=val_idg, callbacks = [tf_call,tf_es],class_weight=cw)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T05:06:19.395605Z","iopub.execute_input":"2023-09-28T05:06:19.396707Z","iopub.status.idle":"2023-09-28T07:15:59.713615Z","shell.execute_reply.started":"2023-09-28T05:06:19.396673Z","shell.execute_reply":"2023-09-28T07:15:59.712617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,4))\nplt.plot(model.history.history['acc'],label='Training Accuracy')\nplt.plot(model.history.history['val_acc'],label='Validation Accuracy')\nplt.legend()\nplt.subplot(1,2,2)\nplt.plot(model.history.history['loss'],label='Training Loss')\nplt.plot(model.history.history['val_loss'],label='Validation Loss')\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:26:47.787516Z","iopub.execute_input":"2023-09-28T07:26:47.787912Z","iopub.status.idle":"2023-09-28T07:26:48.121842Z","shell.execute_reply.started":"2023-09-28T07:26:47.787879Z","shell.execute_reply":"2023-09-28T07:26:48.120861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_model = tf.keras.models.load_model('Model_checkpoint')","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:26:52.101081Z","iopub.execute_input":"2023-09-28T07:26:52.101454Z","iopub.status.idle":"2023-09-28T07:27:33.870171Z","shell.execute_reply.started":"2023-09-28T07:26:52.101422Z","shell.execute_reply":"2023-09-28T07:27:33.869077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_model.summary()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:27:33.877377Z","iopub.execute_input":"2023-09-28T07:27:33.878104Z","iopub.status.idle":"2023-09-28T07:27:34.095495Z","shell.execute_reply.started":"2023-09-28T07:27:33.878067Z","shell.execute_reply":"2023-09-28T07:27:34.094541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_model.save('cassava-leaf-disease-classification.keras')","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:27:34.096801Z","iopub.execute_input":"2023-09-28T07:27:34.097422Z","iopub.status.idle":"2023-09-28T07:27:35.918455Z","shell.execute_reply.started":"2023-09-28T07:27:34.097384Z","shell.execute_reply":"2023-09-28T07:27:35.917699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_true = val_idg.labels","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:27:35.922446Z","iopub.execute_input":"2023-09-28T07:27:35.923382Z","iopub.status.idle":"2023-09-28T07:27:35.928202Z","shell.execute_reply.started":"2023-09-28T07:27:35.923341Z","shell.execute_reply":"2023-09-28T07:27:35.927289Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res = final_model.predict(val_idg)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:27:35.929677Z","iopub.execute_input":"2023-09-28T07:27:35.930376Z","iopub.status.idle":"2023-09-28T07:29:18.936349Z","shell.execute_reply.started":"2023-09-28T07:27:35.930343Z","shell.execute_reply":"2023-09-28T07:29:18.935376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = np.argmax(res, axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:29:18.938078Z","iopub.execute_input":"2023-09-28T07:29:18.938433Z","iopub.status.idle":"2023-09-28T07:29:18.943611Z","shell.execute_reply.started":"2023-09-28T07:29:18.938397Z","shell.execute_reply":"2023-09-28T07:29:18.942348Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score, classification_report, confusion_matrix,ConfusionMatrixDisplay","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:29:18.945459Z","iopub.execute_input":"2023-09-28T07:29:18.946237Z","iopub.status.idle":"2023-09-28T07:29:18.956706Z","shell.execute_reply.started":"2023-09-28T07:29:18.946204Z","shell.execute_reply":"2023-09-28T07:29:18.955598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(y_pred == y_true).mean()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.124069Z","iopub.execute_input":"2023-09-28T07:19:22.124429Z","iopub.status.idle":"2023-09-28T07:19:22.132145Z","shell.execute_reply.started":"2023-09-28T07:19:22.124392Z","shell.execute_reply":"2023-09-28T07:19:22.131164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"confusion_matrix(y_true,y_pred)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.133551Z","iopub.execute_input":"2023-09-28T07:19:22.134686Z","iopub.status.idle":"2023-09-28T07:19:22.148993Z","shell.execute_reply.started":"2023-09-28T07:19:22.134650Z","shell.execute_reply":"2023-09-28T07:19:22.147682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_true,y_pred)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.150441Z","iopub.execute_input":"2023-09-28T07:19:22.151005Z","iopub.status.idle":"2023-09-28T07:19:22.161213Z","shell.execute_reply.started":"2023-09-28T07:19:22.150969Z","shell.execute_reply":"2023-09-28T07:19:22.160026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(classification_report(y_true,y_pred))","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.162984Z","iopub.execute_input":"2023-09-28T07:19:22.163457Z","iopub.status.idle":"2023-09-28T07:19:22.180958Z","shell.execute_reply.started":"2023-09-28T07:19:22.163425Z","shell.execute_reply":"2023-09-28T07:19:22.179962Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.182500Z","iopub.execute_input":"2023-09-28T07:19:22.182857Z","iopub.status.idle":"2023-09-28T07:19:22.191019Z","shell.execute_reply.started":"2023-09-28T07:19:22.182826Z","shell.execute_reply":"2023-09-28T07:19:22.190120Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,12))\nConfusionMatrixDisplay(confusion_matrix(y_true,y_pred)).plot()","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.192573Z","iopub.execute_input":"2023-09-28T07:19:22.193214Z","iopub.status.idle":"2023-09-28T07:19:22.591429Z","shell.execute_reply.started":"2023-09-28T07:19:22.193182Z","shell.execute_reply":"2023-09-28T07:19:22.590523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = tf.keras.preprocessing.image.load_img('/kaggle/input/cassava-leaf-disease-classification/test_images/2216849948.jpg',target_size=(300,400,3))\nimg","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.592907Z","iopub.execute_input":"2023-09-28T07:19:22.593873Z","iopub.status.idle":"2023-09-28T07:19:22.645603Z","shell.execute_reply.started":"2023-09-28T07:19:22.593838Z","shell.execute_reply":"2023-09-28T07:19:22.644856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_img_arr = tf.keras.preprocessing.image.img_to_array(img)\ntest_img_arr = np.expand_dims(test_img_arr,axis=0)\ntest_img_arr.shape","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.646741Z","iopub.execute_input":"2023-09-28T07:19:22.647723Z","iopub.status.idle":"2023-09-28T07:19:22.655178Z","shell.execute_reply.started":"2023-09-28T07:19:22.647691Z","shell.execute_reply":"2023-09-28T07:19:22.654381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res = final_model.predict(test_img_arr)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:19:22.656297Z","iopub.execute_input":"2023-09-28T07:19:22.657197Z","iopub.status.idle":"2023-09-28T07:19:29.795385Z","shell.execute_reply.started":"2023-09-28T07:19:22.657123Z","shell.execute_reply":"2023-09-28T07:19:29.794378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = np.argmax(res, axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:45:17.220594Z","iopub.execute_input":"2023-09-28T07:45:17.220993Z","iopub.status.idle":"2023-09-28T07:45:17.228409Z","shell.execute_reply.started":"2023-09-28T07:45:17.220962Z","shell.execute_reply":"2023-09-28T07:45:17.227232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[data.index==y_pred[0]]","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:45:25.504309Z","iopub.execute_input":"2023-09-28T07:45:25.504721Z","iopub.status.idle":"2023-09-28T07:45:25.516448Z","shell.execute_reply.started":"2023-09-28T07:45:25.504687Z","shell.execute_reply":"2023-09-28T07:45:25.515035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result = pd.DataFrame()\nresult['image_id'] = ['2216849948.jpg']\nresult['label'] = y_pred[0]","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:45:35.356279Z","iopub.execute_input":"2023-09-28T07:45:35.356685Z","iopub.status.idle":"2023-09-28T07:45:35.364367Z","shell.execute_reply.started":"2023-09-28T07:45:35.356640Z","shell.execute_reply":"2023-09-28T07:45:35.363207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:45:37.170717Z","iopub.execute_input":"2023-09-28T07:45:37.171101Z","iopub.status.idle":"2023-09-28T07:45:37.181311Z","shell.execute_reply.started":"2023-09-28T07:45:37.171071Z","shell.execute_reply":"2023-09-28T07:45:37.179882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result.to_csv('submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-09-28T07:45:51.892432Z","iopub.execute_input":"2023-09-28T07:45:51.892815Z","iopub.status.idle":"2023-09-28T07:45:51.905774Z","shell.execute_reply.started":"2023-09-28T07:45:51.892784Z","shell.execute_reply":"2023-09-28T07:45:51.904863Z"},"trusted":true},"execution_count":null,"outputs":[]}]}