{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"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 in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport shutil\nimport time\nimport gc\nfrom tqdm import tqdm\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n# Any results you write to the current directory are saved as output.\n\n'''from sklearn.model_selection import train_test_split\nfrom keras import models,callbacks,layers,utils,optimizers\nfrom keras.preprocessing.image import ImageDataGenerator\nfrom keras.applications import resnet50'''\n\nfrom fastai.vision import *\nfrom fastai.metrics import error_rate","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"de43831ac261198791a15ed3170a6ad34b9a58fb"},"cell_type":"code","source":"df=pd.read_csv('../input/train.csv')\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e395d753cf1b62d26459988d00e4ecc9b5387196"},"cell_type":"code","source":"df.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f63bc892c4fa7114190edbd96e0d573ac95b596b"},"cell_type":"code","source":"df['total_count'] = df.groupby('Id')['Id'].transform('count')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6524fbce3b0cf9d8f8725ee90df20c37b177a2ac"},"cell_type":"code","source":"df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"599612a39f5bfb9081d63bb1265bb6008ea284bd"},"cell_type":"code","source":"df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"70e727749d820283b33db38f7d82bc92cf9f223e"},"cell_type":"code","source":"df_grouped = df.groupby('Id').apply(lambda x : x.sample(frac=0.2,random_state=22))\ndf_grouped.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4aed7882b056ccf51f443e63dba5516e7e47a9c2"},"cell_type":"code","source":"df_grouped.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"729e48e4a217fcd6808ca4172d42716deeb1819b"},"cell_type":"code","source":"df_grouped.tail(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7616291b03703dfede54dd3ed3a1edfe3ba0871b"},"cell_type":"code","source":"df_merged = pd.merge(left=df,right=df_grouped,how='left',on='Image',suffixes=('','_y'))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d615fd3de10c1cdaec508dad2380ef091bc209ce"},"cell_type":"code","source":"df_merged['is_valid'] = df_merged.Id_y.isnull() != True\ndf_merged.tail(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"723da2d02d890ea6fb5009aaf7e9ba1b11f2328d"},"cell_type":"code","source":"df_merged.drop(columns=['Id_y','total_count_y'],inplace=True)\ndf_merged.tail(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f8696982eb8e632cb88cb63dfc6059b14a52462e"},"cell_type":"code","source":"del df_grouped\ndel df\ngc.collect()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6c03a98af766f86cc1bf40ee9822d81972971711"},"cell_type":"code","source":"data_src=(ImageItemList.from_df(df=df_merged,path='../input/',folder='train')\n       #Where to find the data? \n       .split_from_df(col='is_valid')\n       #How to split in train/valid?\n       .label_from_df(cols='Id'))         ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3cdf6fcb53e37da7b49e6ca3dc8517bc900aed50"},"cell_type":"code","source":"data= (data_src       \n       .add_test_folder(test_folder='../input/test/')\n       #Optionally add a test set\n       .transform(get_transforms(do_flip=False),size=224)\n       #Data augmentation?           \n       .databunch(num_workers=0)\n       #Finally? -> use the defaults for conversion to ImageDataBunch\n      .normalize(imagenet_stats))\n      \n        \n       ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"349a83502f5b95276ee027e94b8468c8add31bc5"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c72d9ac08076be8b6e381d3ed356023cf24c4e9d"},"cell_type":"code","source":"print('Batch size:',data.batch_size, '\\nTotal Classes:',data.c,'\\n')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f7668c9a14268c4577c987f147c6b86107fe9915"},"cell_type":"code","source":"data.show_batch(rows=3,figsize=(10,10))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"82a25816e12aa4e3f28715d0c1baa56ef5c2ce37"},"cell_type":"code","source":"learn = create_cnn(data=data,arch=models.resnet50,metrics=error_rate,model_dir='.',path='../working/tmp/',pretrained=True)\n#learn = create_cnn(data=data,arch=models.resnet18,metrics=error_rate,model_dir='.',callback_fns=ShowGraph)\nlearn.model","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1436fe540dc072b8ad2b73fe069b5728cca8261d","scrolled":false},"cell_type":"code","source":"learn.lr_find()\nlearn.recorder.plot()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8f6e45318b658b94b594481b9465361b8d6ff2c2"},"cell_type":"code","source":"# learn.fit_one_cycle(4)\nlearn.fit_one_cycle(7,max_lr=slice(1e-04,1e-02))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ab197635f3ea599eb119a75a7671ebcaceb5e5f7"},"cell_type":"code","source":"learn.save('stage-1_res18')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0696d84369b8907960b0925ade5d43da39524ec0"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b8811330742eda3d98eec3e9f32bb4220f11a650"},"cell_type":"code","source":"learn.unfreeze()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"47f7229be61613e299d25b857f7576134c601dc0"},"cell_type":"code","source":"learn.lr_find()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fbfe506cac35102f5dcd156d22c34da2b90d6968"},"cell_type":"code","source":"learn.recorder.plot()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b18c871a875c9450af4a315d46791070d76d1c52"},"cell_type":"code","source":"learn.fit_one_cycle(7, max_lr=slice(1e-9,1e-6))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8239dddbec6d2cb9cf6de158194bd40383959e2d"},"cell_type":"code","source":"learn.save('stage-2_res18')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3fc4378bc37d4cb637f3a04630a51dea174d7605"},"cell_type":"code","source":"# data= (data_src       \n#        .add_test_folder(test_folder='../input/test/')\n#        #Optionally add a test set\n#        .transform(get_transforms(do_flip=False),size=320)\n#        #Data augmentation?           \n#        .databunch(num_workers=0)\n#        #Finally? -> use the defaults for conversion to ImageDataBunch\n#       .normalize(imagenet_stats))                 ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"388ece5f3c9a7ea64dba350f546513be2a2cafd8"},"cell_type":"code","source":"# learn.save('stage-Final_res18')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d11de0e114e837703cb547949f9caf0937487108"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5d6eb1860a9fab4d767b35d678d789bffa98c512"},"cell_type":"code","source":"os.listdir('../working/tmp/')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"528f71e443276276b686852652bbdc83ce3b479e"},"cell_type":"code","source":"learn.recorder.plot_losses()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"77e683c0260dcedd14556b8004a7c42398ce7a85"},"cell_type":"code","source":"learn.recorder.plot_lr()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4d1e1adaca3243effbe80516343cf4192faf42d3"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3a9695ed83c264dfeccffba72c96f55833de777a"},"cell_type":"code","source":"interp = ClassificationInterpretation.from_learner(learn)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8f5934c2b9f028ed748082cbed85190a52e59744"},"cell_type":"code","source":"#interp.plot_confusion_matrix()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b47709d8fc6fcc4c3ef480039af104d9ee286972"},"cell_type":"code","source":"losses,idxs = interp.top_losses()\nlen(data.valid_ds)==len(losses)==len(idxs)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"13a65fa878f3fd951ba07a13f62b35dd37f0af08"},"cell_type":"code","source":"interp.plot_top_losses(9, figsize=(15,11))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c45833cf66aafc9326615062b4e3fdfa6675709b"},"cell_type":"code","source":"\n#interp.most_confused()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"70a6ab7991f1588537d924de40b39fd1a0b6d053"},"cell_type":"code","source":"# img=learn.data.train_ds[0][0]\n# learn.predict(img)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3e4b046f58f385914862e45c74490820db719d68"},"cell_type":"code","source":"#preds,y = learn.TTA()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"af70bbc3a71075e585f1ed57c2263b34573aef35"},"cell_type":"code","source":"#preds_t,y_t = learn.TTA(ds_type=learn.data.train_ds[:100],is_test=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d7ea198d6c1554bcc760b4b12edd381f55ddf193"},"cell_type":"code","source":"# #preds_t = np.stack(preds, axis=-1)\n# preds_t = np.exp(preds_t)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3eb040c348096fb667cb44b575550b2eb1d2565e"},"cell_type":"code","source":"# preds_t = preds_t.mean(axis=-1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0befbf5b55ed6e08ceb39abc489b490f19d90a61"},"cell_type":"code","source":"# preds_t.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"26b46ae7d170fbcd317be9d4700b529ff4fa0434"},"cell_type":"code","source":"# data.train_ds","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"84cf5c8fbfcf36bb9be8de79f8e30505c8cc9bfe"},"cell_type":"code","source":"# preds=learn.pred_batch(ds_type=data.test_ds)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c85179d60075c9def4789c8ee0bbf5e788511491"},"cell_type":"code","source":"# preds[0].shape,preds[1].shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"309e91ba40f2e7ec14a355c961554d179eb4b13f"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d043e34c2bdaf0daa28dea2f0c2d1f639bafa1ee"},"cell_type":"code","source":"len(learn.data.train_ds),len(learn.data.valid_ds),len(learn.data.test_ds)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"67f1453e1bf9755af7ef8ca2a41f7a1843f7a77d"},"cell_type":"code","source":"len(data.train_ds),len(data.valid_ds), len(data.test_ds)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"283bfed3c4d61197d63dda0f2e4c8b1bd525c273"},"cell_type":"code","source":"# preds = learn.predict()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"379dcc50f7c914cee569d64e0b4d8df0c5f7da4f"},"cell_type":"code","source":"#LRFinder??\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"94c88b6114d9f2162be21e7b72c2b2564d1633a4"},"cell_type":"code","source":"len(data.train_ds),len(data.valid_ds), len(data.test_ds)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c3f4b8448622cd0f2fcb688e2f0b12805e2135b3"},"cell_type":"code","source":"# learn.show_results(ds_type=DatasetType.Train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"59047af07888316dd4cdd7f273c3d1a29c3e4226"},"cell_type":"code","source":" #learn.show_results(ds_type=DatasetType.Test)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4ef5d6a48e5c714c2e30f8519f7f7690b52bc61c"},"cell_type":"code","source":"#pred = learn.predict(DatasetType.Test)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d71e4594736878b4fae101c6e08b42a5ff3b7a8c"},"cell_type":"code","source":"pred_2=learn.TTA(ds_type=DatasetType.Test)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d3d7a0881221bab94ba877e0349531e881ba4e2e"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"37f4dcda8d3d510553e951a11ae0f432d80264c2"},"cell_type":"code","source":"best_5_pred = torch.flip(np.argsort(pred_2[0])[:,-5:],dims=[1])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2d7ba2b47727037191195579d1d95259d9de1215"},"cell_type":"code","source":"#Generate mapping of each index to an Id on the format\npred_label = []\nfor i in best_5_pred:\n    temp=[]\n    temp_str=''\n    for name in i:\n        temp.append(data.classes[name])         \n    temp_str =' '.join(temp)\n    pred_label.append(temp_str)    ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1f48d1aac56190346b5bb39a5686b811f4108f61"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"aa8183155e66dd75a8bcedd92d58d0568b50b3e7"},"cell_type":"code","source":"submission = pd.DataFrame({\"Image\": os.listdir('../input/test/'), \"Id\": pred_label})\nsubmission.to_csv(\"submission.csv\", index = False)\nsubmission.head(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f61d06fc94c608629654b5c7db66bff01447f629"},"cell_type":"code","source":"submission.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"21375379a6468c9d6a078c9705da85b516ba8b62"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fe446f8e2968c4006b485fab985a7093f342c257"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d387a368b233a71cc9dd91974a12fa9f05c37436"},"cell_type":"code","source":"#train_labels = df[~(df.Id == 'new_whale')]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c5c01eb254e13210c2d46c45e8571db43b87860c"},"cell_type":"code","source":"#train,val = train_test_split(df.Id,df.index,stratify=df.index)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d000a0716708e14108d51c55bf8d00c7851c1e29"},"cell_type":"code","source":"#train.shape, val.shape","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"#df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"29ad7b7fd7445e8b57b840f8d0d78504cf9df7ba"},"cell_type":"code","source":"#train_labels.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"16d31ebd812e815ff9450ffebe525b1924581bc4"},"cell_type":"code","source":"#train_labels.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"19e06cc5d8a03daaeca29b5617377bfff465dbbb"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7a16ef53ed49f49169625870a5427999fd789483"},"cell_type":"code","source":"# Define data pre-processing \n#train_image_gen = ImageDataGenerator(rescale=1/255,horizontal_flip=True,validation_split=val_split,)\n\n#train_image_gen = ImageDataGenerator(rotation_range=0.3, width_shift_range=0.3, height_shift_range=0.3,shear_range=0.3, horizontal_flip=True, rescale=1/255, preprocessing_function=resnet50.preprocess_input, validation_split=val_split)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f75a6a81a8ff52d8125e56aa4aab62e998017241"},"cell_type":"code","source":"#train_generator = train_image_gen.flow_from_directory(train_dir,target_size=(Image_width,Image_height),batch_size=batch_size,seed=42,subset='training',shuffle=True,class_mode='categorical')\n#val_generator = train_image_gen.flow_from_directory(train_dir,target_size=(Image_width,Image_height),batch_size=batch_size,seed=42,subset='validation',shuffle=True,class_mode='categorical')\n#train_generator=train_image_gen.flow_from_dataframe(dataframe=train_labels,directory='../input/train/',x_col='Image',y_col='Id',seed=42,has_ext=True,class_mode='categorical',target_size=(Image_width,Image_height),subset='training')\n#val_generator=train_image_gen.flow_from_dataframe(dataframe=train_labels,directory='../input/train/',x_col='Image',y_col='Id',seed=42,has_ext=True,class_mode='categorical',target_size=(Image_width,Image_height),subset='validation')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"13bb4ff36c8276200d2fd69fd13a41b088b0c591"},"cell_type":"code","source":"#reset50_base_model = resnet50.ResNet50(include_top=False, weights='imagenet')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"scrolled":false,"_uuid":"5699facaa92cf8adf74a59c87666ba05af0db20f"},"cell_type":"code","source":"# res = reset50_base_model.output\n# res_pool = layers.GlobalAveragePooling2D()(res)\n# res_dense = layers.Dense(units=Number_FC_Neurons,activation='relu')(res_pool)\n# final_pred = layers.Dense(num_classes,activation='softmax')(res_dense)\n# model = models.Model(inputs=reset50_base_model.input,output=final_pred)\n# model.summary()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"52bc27d3db9d61976fc4ace9d36ae17a390960f5"},"cell_type":"code","source":"# cb_checkpoint = callbacks.ModelCheckpoint(filepath='../working/best.hd5',monitor='val_loss',save_best_only=True,mode=min)\n# cb_stopping = callbacks.EarlyStopping(monitor='val_loss',mode=min,patience=2,restore_best_weights=True)\n# my_callback = [cb_checkpoint,cb_stopping]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"81b4d4f3c514bfbd81fdb2396b235133b4d07c54"},"cell_type":"code","source":"# layers_to_freeze=130\n# for layer in model.layers[:layers_to_freeze]:\n#     layer.trainable=False\n\n# for layer in model.layers[layers_to_freeze:]:\n#     layer.trainable=True\n    \n# #sgd = optimizers.SGD(lr=0.01,decay=1e-6,momentum=0.9,nesterov=True)\n# model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ceefe1bdd481665fe1485a5e97a7d1049039fc8e"},"cell_type":"code","source":"#train_step = train_generator.n//train_generator.batch_size\n#val_step= val_generator.n//val_generator.batch_size","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c39c21ed96e7d53788cc21c960cbdbead77b22d8"},"cell_type":"code","source":"#learnings = model.fit_generator(train_generator,epochs=2,steps_per_epoch=train_step,validation_data=val_generator,validation_steps=val_step,verbose=1,callbacks=my_callback,class_weight='auto')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3c6cbfc6b805050b63c193daadcbaac579e76cca"},"cell_type":"code","source":"#test_dir='../data/'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ac12068722acc2069badf16341782736223ee735"},"cell_type":"code","source":"# Define data pre-processing \n#test_image_gen = ImageDataGenerator(rescale=1./255)\n#test_generator = test_image_gen.flow_from_directory(test_dir,target_size=(Image_width,Image_height),batch_size=1,seed=42,class_mode=None,shuffle=False)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5228572dd76a6ccf3974796ea038b8ee17fa5d37"},"cell_type":"code","source":"#test_generator.reset()\n#y_pred = model.predict_generator(generator=test_generator,verbose=1,)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"373c7bfc800265029963c089bea07c22d9266d61"},"cell_type":"code","source":"#best_5_pred = np.flip(axis=1,m=np.argsort(y_pred)[:,-5:])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d80a07b3789b2053394ef8f56d4766b550d5d7f4"},"cell_type":"code","source":"#Generate mapping of each index to an Id on the format\n#mapIndex = dict((v,k) for (k,v) in train_generator.class_indices.items())","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ffe88ca632346dd47ca8e5daaf71fab0cada43b2"},"cell_type":"code","source":"#submission.loc[submission['Image']=='000dcf7d8.jpg']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5d350664aad499538aab2b391aa51d2b858080e6"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}