{"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 efficientnet_pytorch","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-09-17T06:09:35.486260Z","iopub.execute_input":"2021-09-17T06:09:35.486603Z","iopub.status.idle":"2021-09-17T06:09:45.356470Z","shell.execute_reply.started":"2021-09-17T06:09:35.486489Z","shell.execute_reply":"2021-09-17T06:09:45.355483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### References :\n* https://www.kaggle.com/abhishek/accelerator-power-hour-pytorch-tpu\n* https://www.kaggle.com/kevin9000/melanoma-beginner-cnn-using-pytorch\n* https://www.kaggle.com/abhishek/melanoma-detection-with-pytorch?scriptVersionId=35193166\n* https://www.kaggle.com/nvnvashisth/pytorch-efficientnet-b0-gpu\n* https://www.kaggle.com/shebinscaria/siim-isic-efficientnet-starter-code\n* https://www.youtube.com/watch?v=QxJgKPdEBV4\n* https://www.youtube.com/watch?v=WaCFd-vL4HA\n* https://towardsdatascience.com/cuda-error-device-side-assert-triggered-c6ae1c8fa4c3","metadata":{}},{"cell_type":"code","source":"!pip install wtfml==0.0.2","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:45.359292Z","iopub.execute_input":"2021-09-17T06:09:45.359664Z","iopub.status.idle":"2021-09-17T06:09:52.037182Z","shell.execute_reply.started":"2021-09-17T06:09:45.359624Z","shell.execute_reply":"2021-09-17T06:09:52.036222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nfrom PIL import Image\n\nfrom sklearn import model_selection\nfrom sklearn import metrics\n\nimport torch\nimport torch.nn as nn\nfrom torch.nn import functional as F\nimport torch.optim as optim\nimport efficientnet_pytorch\n\nimport albumentations as A\n\nfrom wtfml.utils import EarlyStopping\nfrom wtfml.engine import Engine\nfrom wtfml.data_loaders.image import ClassificationLoader\n\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n\n# from wtfml.classification import ClassificationDataLoader\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":{"execution":{"iopub.status.busy":"2021-09-17T06:17:52.309994Z","iopub.execute_input":"2021-09-17T06:17:52.310338Z","iopub.status.idle":"2021-09-17T06:17:52.317205Z","shell.execute_reply.started":"2021-09-17T06:17:52.310304Z","shell.execute_reply":"2021-09-17T06:17:52.316020Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Exploring Dataset","metadata":{}},{"cell_type":"code","source":"train_dir = '../input/siic-isic-224x224-images/train'\ntest_dir = '../input/siic-isic-224x224-images/test'","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:55.251660Z","iopub.execute_input":"2021-09-17T06:09:55.251994Z","iopub.status.idle":"2021-09-17T06:09:55.258353Z","shell.execute_reply.started":"2021-09-17T06:09:55.251959Z","shell.execute_reply":"2021-09-17T06:09:55.257491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"t = os.listdir(train_dir)\n\nt1 = os.listdir(test_dir)\nprint(len(t),len(t1),len(t)+len(t1))","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:55.259866Z","iopub.execute_input":"2021-09-17T06:09:55.260244Z","iopub.status.idle":"2021-09-17T06:09:57.634570Z","shell.execute_reply.started":"2021-09-17T06:09:55.260206Z","shell.execute_reply":"2021-09-17T06:09:57.633635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imgpath = '../input/siic-isic-224x224-images/test/ISIC_0052060.png'\nimg = Image.open(imgpath)\nimg","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.635883Z","iopub.execute_input":"2021-09-17T06:09:57.636395Z","iopub.status.idle":"2021-09-17T06:09:57.693489Z","shell.execute_reply.started":"2021-09-17T06:09:57.636353Z","shell.execute_reply":"2021-09-17T06:09:57.692692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img2np = np.array(img)\nimg2np.shape","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.694550Z","iopub.execute_input":"2021-09-17T06:09:57.694854Z","iopub.status.idle":"2021-09-17T06:09:57.702051Z","shell.execute_reply.started":"2021-09-17T06:09:57.694821Z","shell.execute_reply":"2021-09-17T06:09:57.701004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ten = torch.from_numpy(img2np)\nten.shape","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.705500Z","iopub.execute_input":"2021-09-17T06:09:57.706223Z","iopub.status.idle":"2021-09-17T06:09:57.717273Z","shell.execute_reply.started":"2021-09-17T06:09:57.706185Z","shell.execute_reply":"2021-09-17T06:09:57.716283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Create folds in dataset","metadata":{}},{"cell_type":"code","source":"input_path = '../input/siim-isic-melanoma-classification/train.csv'\ndf = pd.read_csv(input_path)\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.720547Z","iopub.execute_input":"2021-09-17T06:09:57.721088Z","iopub.status.idle":"2021-09-17T06:09:57.825354Z","shell.execute_reply.started":"2021-09-17T06:09:57.721055Z","shell.execute_reply":"2021-09-17T06:09:57.824495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['kfold'] = -1\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.826649Z","iopub.execute_input":"2021-09-17T06:09:57.827035Z","iopub.status.idle":"2021-09-17T06:09:57.845113Z","shell.execute_reply.started":"2021-09-17T06:09:57.826992Z","shell.execute_reply":"2021-09-17T06:09:57.843736Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.sample(frac = 1).head()","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.846846Z","iopub.execute_input":"2021-09-17T06:09:57.847204Z","iopub.status.idle":"2021-09-17T06:09:57.870388Z","shell.execute_reply.started":"2021-09-17T06:09:57.847167Z","shell.execute_reply":"2021-09-17T06:09:57.869305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.sample(frac = 1).reset_index(drop = True) #shuffling the data, and reset index\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.871771Z","iopub.execute_input":"2021-09-17T06:09:57.872112Z","iopub.status.idle":"2021-09-17T06:09:57.896865Z","shell.execute_reply.started":"2021-09-17T06:09:57.872078Z","shell.execute_reply":"2021-09-17T06:09:57.895955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = df.target.values\nlen(y)","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.898182Z","iopub.execute_input":"2021-09-17T06:09:57.898586Z","iopub.status.idle":"2021-09-17T06:09:57.905570Z","shell.execute_reply.started":"2021-09-17T06:09:57.898548Z","shell.execute_reply":"2021-09-17T06:09:57.904244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Stratified K-Fold","metadata":{}},{"cell_type":"code","source":"kf = model_selection.StratifiedKFold(n_splits=5)\nfor fold_,(train_idx, test_idx) in enumerate(kf.split(X=df,y=y)):\n    df.loc[test_idx,'kfold'] = fold_\ndf.to_csv('./train_folds.csv')","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:57.907410Z","iopub.execute_input":"2021-09-17T06:09:57.907940Z","iopub.status.idle":"2021-09-17T06:09:58.099323Z","shell.execute_reply.started":"2021-09-17T06:09:57.907906Z","shell.execute_reply":"2021-09-17T06:09:58.098553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ddf = pd.read_csv('./train_folds.csv')\nddf","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.100559Z","iopub.execute_input":"2021-09-17T06:09:58.100904Z","iopub.status.idle":"2021-09-17T06:09:58.171262Z","shell.execute_reply.started":"2021-09-17T06:09:58.100869Z","shell.execute_reply":"2021-09-17T06:09:58.170069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Custom Dataset","metadata":{}},{"cell_type":"code","source":"# fold is an integer for k-fold.val kfold is fold rest training\ndef train(fold):\n    training_data_path = train_dir\n    df = pd.read_csv('./train_folds.csv')\n    device = \"cuda\"\n    epochs = 50\n    train_bs = 32\n    valid_bs = 16\n    \n    df_train = df[df.kfold != fold].reset_index(drop=True)\n    df_valid = df[df.kfold == fold].reset_index(drop=True)\n    \n    # Normalize the images\n    mean = (0.485, 0.456, 0.406)\n    std = (0.229, 0.224, 0.225)\n    ","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.173188Z","iopub.execute_input":"2021-09-17T06:09:58.173590Z","iopub.status.idle":"2021-09-17T06:09:58.180208Z","shell.execute_reply.started":"2021-09-17T06:09:58.173553Z","shell.execute_reply":"2021-09-17T06:09:58.179148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Model Transfer Learning","metadata":{}},{"cell_type":"code","source":"# fold is an integer ie if fold == that no then val else train\ndef train(fold):\n    training_data_path = \"../input/siic-isic-224x224-images/train/\"\n    df = pd.read_csv(\"/kaggle/working/train_folds.csv\")\n    device = \"cuda\"\n    epochs = 50\n    train_bs = 32\n    valid_bs = 16\n\n    df_train = df[df.kfold != fold].reset_index(drop=True)\n    df_valid = df[df.kfold == fold].reset_index(drop=True)\n    \n    mean = (0.485, 0.456, 0.406)\n    std = (0.229, 0.224, 0.225)\n\n    ","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.181857Z","iopub.execute_input":"2021-09-17T06:09:58.182401Z","iopub.status.idle":"2021-09-17T06:09:58.193840Z","shell.execute_reply.started":"2021-09-17T06:09:58.182364Z","shell.execute_reply":"2021-09-17T06:09:58.193027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# IMP for Stratified K-Folds\nfold = 0","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.195291Z","iopub.execute_input":"2021-09-17T06:09:58.195723Z","iopub.status.idle":"2021-09-17T06:09:58.203394Z","shell.execute_reply.started":"2021-09-17T06:09:58.195655Z","shell.execute_reply":"2021-09-17T06:09:58.202525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_data_path = \"../input/siic-isic-224x224-images/train/\"\ndf = pd.read_csv(\"/kaggle/working/train_folds.csv\")\n\nmean = (0.485, 0.456, 0.406)\nstd = (0.229, 0.224, 0.225)\n    \ndf_train = df[df.kfold != fold].reset_index(drop=True)\ndf_valid = df[df.kfold == fold].reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.206342Z","iopub.execute_input":"2021-09-17T06:09:58.206926Z","iopub.status.idle":"2021-09-17T06:09:58.286133Z","shell.execute_reply.started":"2021-09-17T06:09:58.206711Z","shell.execute_reply":"2021-09-17T06:09:58.285292Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# df_train.image_name.values.tolist()\ndevice = \"cuda\"\nepochs = 50\ntrain_bs = 32\nvalid_bs = 16","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.287709Z","iopub.execute_input":"2021-09-17T06:09:58.288320Z","iopub.status.idle":"2021-09-17T06:09:58.292525Z","shell.execute_reply.started":"2021-09-17T06:09:58.288283Z","shell.execute_reply":"2021-09-17T06:09:58.291742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Train\ntraining_data_path = \"../input/siic-isic-224x224-images/train/\"\n\ntrain_aug = A.Compose(\n        [\n            A.Normalize(mean, std, max_pixel_value=255.0, always_apply=True),\n            A.ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.1, rotate_limit=15),\n            A.Flip(p=0.5)  \n        ]          \n    )\n\ntrain_images = df_train.image_name.values.tolist()\ntrain_images = [os.path.join(training_data_path, i + '.png') for i in train_images]\ntrain_targets = df_train.target.values\n\n\ntrain_dataset = ClassificationLoader(\n    image_paths=train_images,\n    targets=train_targets,\n    resize=None,\n    augmentations=train_aug,\n)\n\ntrain_loader = torch.utils.data.DataLoader(\n        train_dataset, batch_size=train_bs, shuffle=True, num_workers=4)","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.293937Z","iopub.execute_input":"2021-09-17T06:09:58.294536Z","iopub.status.idle":"2021-09-17T06:09:58.353049Z","shell.execute_reply.started":"2021-09-17T06:09:58.294476Z","shell.execute_reply":"2021-09-17T06:09:58.352126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Valid\nvalid_images = df_valid.image_name.values.tolist()\nvalid_images = [os.path.join(training_data_path, i + \".png\") for i in valid_images]\nvalid_targets = df_valid.target.values\n\nvalid_aug = A.Compose([\n    A.Normalize(mean, std, max_pixel_value=255.0, always_apply=True)\n])\n\nvalid_dataset = ClassificationLoader(\n    image_paths=valid_images,\n    targets=valid_targets,\n    resize=None,\n    augmentations=valid_aug,\n)\n\nvalid_loader = torch.utils.data.DataLoader(\n        valid_dataset, batch_size=valid_bs, shuffle=False, num_workers=4)","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.354527Z","iopub.execute_input":"2021-09-17T06:09:58.354911Z","iopub.status.idle":"2021-09-17T06:09:58.379932Z","shell.execute_reply.started":"2021-09-17T06:09:58.354871Z","shell.execute_reply":"2021-09-17T06:09:58.379097Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Model Training - Efficient Net","metadata":{}},{"cell_type":"code","source":"class EfficientNet(nn.Module):\n    def __init__(self):\n        super(EfficientNet, self).__init__()\n        self.base_model = efficientnet_pytorch.EfficientNet.from_pretrained(\n            'efficientnet-b4'\n        )\n        self.base_model._fc = nn.Linear(\n            in_features=1792, \n            out_features=1, \n            bias=True\n        )\n        \n    def forward(self, image, targets):\n        out = self.base_model(image)\n        loss = nn.BCEWithLogitsLoss()(out, targets.view(-1, 1).type_as(out))\n        return out, loss","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.383684Z","iopub.execute_input":"2021-09-17T06:09:58.383942Z","iopub.status.idle":"2021-09-17T06:09:58.390560Z","shell.execute_reply.started":"2021-09-17T06:09:58.383918Z","shell.execute_reply":"2021-09-17T06:09:58.389468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = EfficientNet()\nmodel.to(device)","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:09:58.392819Z","iopub.execute_input":"2021-09-17T06:09:58.393274Z","iopub.status.idle":"2021-09-17T06:10:05.408137Z","shell.execute_reply.started":"2021-09-17T06:09:58.393232Z","shell.execute_reply":"2021-09-17T06:10:05.407361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# net = efficientnet_pytorch.EfficientNet.from_pretrained(\n#             'efficientnet-b4'\n#         )","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:10:05.409460Z","iopub.execute_input":"2021-09-17T06:10:05.409842Z","iopub.status.idle":"2021-09-17T06:10:05.414038Z","shell.execute_reply.started":"2021-09-17T06:10:05.409804Z","shell.execute_reply":"2021-09-17T06:10:05.412936Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"device","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:10:05.415614Z","iopub.execute_input":"2021-09-17T06:10:05.416009Z","iopub.status.idle":"2021-09-17T06:10:05.425628Z","shell.execute_reply.started":"2021-09-17T06:10:05.415967Z","shell.execute_reply":"2021-09-17T06:10:05.424431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# for param in net.parameters():\n#     param.requires_grad = False\n    \n# _fc = nn.Linear(1792,1)\n# net._fc = _fc","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:10:05.427132Z","iopub.execute_input":"2021-09-17T06:10:05.427676Z","iopub.status.idle":"2021-09-17T06:10:05.432188Z","shell.execute_reply.started":"2021-09-17T06:10:05.427640Z","shell.execute_reply":"2021-09-17T06:10:05.431157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"optimizer = torch.optim.Adam(model.parameters(), lr=1e-4)\nscheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(\n        optimizer,\n        patience=3,\n        threshold=0.001,\n        mode=\"max\"\n    )\n\nes = EarlyStopping(patience=5, mode=\"max\")","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:10:05.433789Z","iopub.execute_input":"2021-09-17T06:10:05.434213Z","iopub.status.idle":"2021-09-17T06:10:05.449064Z","shell.execute_reply.started":"2021-09-17T06:10:05.434178Z","shell.execute_reply":"2021-09-17T06:10:05.448281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"epochs = 50\nfor epoch in range(epochs):\n        train_loss = Engine.train(train_loader, model, optimizer, device=device)\n        predictions, valid_loss = Engine.evaluate(\n            valid_loader, model, device=device\n        )\n        predictions = np.vstack((predictions)).ravel()\n        auc = metrics.roc_auc_score(valid_targets, predictions)\n        print(f\"Epoch = {epoch}, AUC = {auc}\")\n        scheduler.step(auc)\n\n        es(auc, model, model_path=f\"model_fold_{fold}.bin\")\n        if es.early_stop:\n            print(\"Early stopping\")\n            break","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:18:19.905435Z","iopub.execute_input":"2021-09-17T06:18:19.905808Z","iopub.status.idle":"2021-09-17T06:58:45.105110Z","shell.execute_reply.started":"2021-09-17T06:18:19.905776Z","shell.execute_reply":"2021-09-17T06:58:45.104285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# torch.save\ntorch.save(model.state_dict(), './modetor.pt')","metadata":{"execution":{"iopub.status.busy":"2021-09-17T07:02:31.751615Z","iopub.execute_input":"2021-09-17T07:02:31.751970Z","iopub.status.idle":"2021-09-17T07:02:31.911415Z","shell.execute_reply.started":"2021-09-17T07:02:31.751935Z","shell.execute_reply":"2021-09-17T07:02:31.910534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Test\ndef predict(fold):\n    print(f\"Generating Predictions for saved model, fold = {fold+1}\")\n    test_data_path = \"/kaggle/input/siic-isic-224x224-images/test\"\n    df_test = pd.read_csv(\"/kaggle/input/siim-isic-melanoma-classification/test.csv\")\n    df_test.loc[:,'target'] = 0\n    \n    #model_path = \"f'/kaggle/working/model_fold{fold}'\"\n    #model_path = '/kaggle/working/model_fold0_epoch0.bin'\n    model_path = './model_fold_0.bin'\n    \n    device = 'cuda'\n    \n    test_bs = 16\n    \n    mean = (0.485, 0.456, 0.406)\n    std = (0.229, 0.224, 0.225)\n    \n    test_aug = A.Compose(\n        [\n            A.Normalize(mean, std, max_pixel_value=255.0, always_apply=True,p=1.0)\n        ]\n    )\n    test_images_list = df_test.image_name.values.tolist()\n    test_images = [os.path.join(test_data_path,i + '.png') for i in test_images_list]\n    test_targets = df_test.target.values\n    \n    test_dataset = ClassificationLoader(\n        image_paths = test_images,\n        targets= test_targets,\n        resize = None,\n        augmentations = test_aug\n    )\n    \n    test_loader = torch.utils.data.DataLoader(\n        test_dataset,\n        batch_size = test_bs,\n        shuffle = False,\n        num_workers=4\n    )\n    #Earlier defined class for model\n    model = EfficientNet()\n    model.load_state_dict(torch.load(model_path))\n    model.to(device)\n    \n    predictions_op = Engine.predict(\n        test_loader,\n        model,\n        device\n    )\n    return np.vstack((predictions_op)).ravel()","metadata":{"execution":{"iopub.status.busy":"2021-09-17T07:11:10.506381Z","iopub.execute_input":"2021-09-17T07:11:10.506740Z","iopub.status.idle":"2021-09-17T07:11:10.516621Z","shell.execute_reply.started":"2021-09-17T07:11:10.506709Z","shell.execute_reply":"2021-09-17T07:11:10.515570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# prediction\npred = predict(0)","metadata":{"execution":{"iopub.status.busy":"2021-09-17T07:11:16.467181Z","iopub.execute_input":"2021-09-17T07:11:16.467517Z","iopub.status.idle":"2021-09-17T07:12:19.951909Z","shell.execute_reply.started":"2021-09-17T07:11:16.467472Z","shell.execute_reply":"2021-09-17T07:12:19.950933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = pred\nsample = pd.read_csv(\"../input/siim-isic-melanoma-classification/sample_submission.csv\")\nsample.loc[:, \"target\"] = predictions\nsample.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2021-09-17T07:14:50.721867Z","iopub.execute_input":"2021-09-17T07:14:50.722228Z","iopub.status.idle":"2021-09-17T07:14:50.778893Z","shell.execute_reply.started":"2021-09-17T07:14:50.722190Z","shell.execute_reply":"2021-09-17T07:14:50.778017Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:17:01.362125Z","iopub.status.idle":"2021-09-17T06:17:01.362671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2021-09-17T06:17:01.363754Z","iopub.status.idle":"2021-09-17T06:17:01.364286Z"},"trusted":true},"execution_count":null,"outputs":[]}]}