{"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":"2022-04-21T09:03:57.561507Z","iopub.execute_input":"2022-04-21T09:03:57.561910Z","iopub.status.idle":"2022-04-21T09:04:06.523015Z","shell.execute_reply.started":"2022-04-21T09:03:57.561823Z","shell.execute_reply":"2022-04-21T09:04:06.522075Z"},"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":"2022-04-21T09:04:06.525455Z","iopub.execute_input":"2022-04-21T09:04:06.525825Z","iopub.status.idle":"2022-04-21T09:04:12.881561Z","shell.execute_reply.started":"2022-04-21T09:04:06.525785Z","shell.execute_reply":"2022-04-21T09:04:12.880611Z"},"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\ntorch.cuda.empty_cache()\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":"2022-04-21T09:04:12.883823Z","iopub.execute_input":"2022-04-21T09:04:12.884204Z","iopub.status.idle":"2022-04-21T09:04:15.821374Z","shell.execute_reply.started":"2022-04-21T09:04:12.884164Z","shell.execute_reply":"2022-04-21T09:04:15.820512Z"},"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":"2022-04-21T09:04:15.823018Z","iopub.execute_input":"2022-04-21T09:04:15.823380Z","iopub.status.idle":"2022-04-21T09:04:15.828463Z","shell.execute_reply.started":"2022-04-21T09:04:15.823343Z","shell.execute_reply":"2022-04-21T09:04:15.827587Z"},"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":"2022-04-21T09:04:15.829895Z","iopub.execute_input":"2022-04-21T09:04:15.830249Z","iopub.status.idle":"2022-04-21T09:04:16.892393Z","shell.execute_reply.started":"2022-04-21T09:04:15.830215Z","shell.execute_reply":"2022-04-21T09:04:16.891538Z"},"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":"2022-04-21T09:04:16.893789Z","iopub.execute_input":"2022-04-21T09:04:16.894128Z","iopub.status.idle":"2022-04-21T09:04:16.938287Z","shell.execute_reply.started":"2022-04-21T09:04:16.894092Z","shell.execute_reply":"2022-04-21T09:04:16.937486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img2np = np.array(img)\nimg2np.shape","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:16.939334Z","iopub.execute_input":"2022-04-21T09:04:16.939638Z","iopub.status.idle":"2022-04-21T09:04:16.946604Z","shell.execute_reply.started":"2022-04-21T09:04:16.939604Z","shell.execute_reply":"2022-04-21T09:04:16.945658Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ten = torch.from_numpy(img2np)\nten.shape","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:16.949838Z","iopub.execute_input":"2022-04-21T09:04:16.950342Z","iopub.status.idle":"2022-04-21T09:04:16.961120Z","shell.execute_reply.started":"2022-04-21T09:04:16.950286Z","shell.execute_reply":"2022-04-21T09:04:16.960294Z"},"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":"2022-04-21T09:04:16.963269Z","iopub.execute_input":"2022-04-21T09:04:16.963678Z","iopub.status.idle":"2022-04-21T09:04:17.058973Z","shell.execute_reply.started":"2022-04-21T09:04:16.963614Z","shell.execute_reply":"2022-04-21T09:04:17.058222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['kfold'] = -1\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:17.060267Z","iopub.execute_input":"2022-04-21T09:04:17.060603Z","iopub.status.idle":"2022-04-21T09:04:17.080261Z","shell.execute_reply.started":"2022-04-21T09:04:17.060568Z","shell.execute_reply":"2022-04-21T09:04:17.079372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.sample(frac = 1).head()","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:17.081604Z","iopub.execute_input":"2022-04-21T09:04:17.081929Z","iopub.status.idle":"2022-04-21T09:04:17.103761Z","shell.execute_reply.started":"2022-04-21T09:04:17.081894Z","shell.execute_reply":"2022-04-21T09:04:17.103042Z"},"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":"2022-04-21T09:04:17.104980Z","iopub.execute_input":"2022-04-21T09:04:17.105401Z","iopub.status.idle":"2022-04-21T09:04:17.130564Z","shell.execute_reply.started":"2022-04-21T09:04:17.105359Z","shell.execute_reply":"2022-04-21T09:04:17.129845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = df.target.values\nlen(y)","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:17.132064Z","iopub.execute_input":"2022-04-21T09:04:17.132604Z","iopub.status.idle":"2022-04-21T09:04:17.138253Z","shell.execute_reply.started":"2022-04-21T09:04:17.132568Z","shell.execute_reply":"2022-04-21T09:04:17.137433Z"},"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":"2022-04-21T09:04:17.139533Z","iopub.execute_input":"2022-04-21T09:04:17.140150Z","iopub.status.idle":"2022-04-21T09:04:17.329348Z","shell.execute_reply.started":"2022-04-21T09:04:17.140095Z","shell.execute_reply":"2022-04-21T09:04:17.328530Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ddf = pd.read_csv('./train_folds.csv')\nddf","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:17.332348Z","iopub.execute_input":"2022-04-21T09:04:17.332637Z","iopub.status.idle":"2022-04-21T09:04:17.402791Z","shell.execute_reply.started":"2022-04-21T09:04:17.332603Z","shell.execute_reply":"2022-04-21T09:04:17.401918Z"},"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":"2022-04-21T09:04:17.404082Z","iopub.execute_input":"2022-04-21T09:04:17.404450Z","iopub.status.idle":"2022-04-21T09:04:17.411197Z","shell.execute_reply.started":"2022-04-21T09:04:17.404415Z","shell.execute_reply":"2022-04-21T09:04:17.410253Z"},"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":"2022-04-21T09:04:17.412569Z","iopub.execute_input":"2022-04-21T09:04:17.413121Z","iopub.status.idle":"2022-04-21T09:04:17.424559Z","shell.execute_reply.started":"2022-04-21T09:04:17.413082Z","shell.execute_reply":"2022-04-21T09:04:17.423634Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# IMP for Stratified K-Folds\nfold = 0","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:17.425817Z","iopub.execute_input":"2022-04-21T09:04:17.426196Z","iopub.status.idle":"2022-04-21T09:04:17.433029Z","shell.execute_reply.started":"2022-04-21T09:04:17.426159Z","shell.execute_reply":"2022-04-21T09:04:17.432070Z"},"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":"2022-04-21T09:04:17.434434Z","iopub.execute_input":"2022-04-21T09:04:17.434839Z","iopub.status.idle":"2022-04-21T09:04:17.512010Z","shell.execute_reply.started":"2022-04-21T09:04:17.434803Z","shell.execute_reply":"2022-04-21T09:04:17.511242Z"},"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":"2022-04-21T09:04:17.514134Z","iopub.execute_input":"2022-04-21T09:04:17.514621Z","iopub.status.idle":"2022-04-21T09:04:17.518781Z","shell.execute_reply.started":"2022-04-21T09:04:17.514584Z","shell.execute_reply":"2022-04-21T09:04:17.517957Z"},"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":"2022-04-21T09:04:17.520211Z","iopub.execute_input":"2022-04-21T09:04:17.520573Z","iopub.status.idle":"2022-04-21T09:04:17.575283Z","shell.execute_reply.started":"2022-04-21T09:04:17.520532Z","shell.execute_reply":"2022-04-21T09:04:17.574569Z"},"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":"2022-04-21T09:04:17.577072Z","iopub.execute_input":"2022-04-21T09:04:17.577541Z","iopub.status.idle":"2022-04-21T09:04:17.595173Z","shell.execute_reply.started":"2022-04-21T09:04:17.577507Z","shell.execute_reply":"2022-04-21T09:04:17.594373Z"},"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":"2022-04-21T09:04:17.599938Z","iopub.execute_input":"2022-04-21T09:04:17.601459Z","iopub.status.idle":"2022-04-21T09:04:17.607095Z","shell.execute_reply.started":"2022-04-21T09:04:17.601423Z","shell.execute_reply":"2022-04-21T09:04:17.606055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = EfficientNet()\nmodel.to(device)","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:17.608682Z","iopub.execute_input":"2022-04-21T09:04:17.609202Z","iopub.status.idle":"2022-04-21T09:04:23.403059Z","shell.execute_reply.started":"2022-04-21T09:04:17.609164Z","shell.execute_reply":"2022-04-21T09:04:23.402220Z"},"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":"2022-04-21T09:04:23.404511Z","iopub.execute_input":"2022-04-21T09:04:23.405061Z","iopub.status.idle":"2022-04-21T09:04:23.408286Z","shell.execute_reply.started":"2022-04-21T09:04:23.405022Z","shell.execute_reply":"2022-04-21T09:04:23.407493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"device","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:04:23.409518Z","iopub.execute_input":"2022-04-21T09:04:23.410051Z","iopub.status.idle":"2022-04-21T09:04:23.418971Z","shell.execute_reply.started":"2022-04-21T09:04:23.410014Z","shell.execute_reply":"2022-04-21T09:04:23.418063Z"},"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":"2022-04-21T09:04:23.420006Z","iopub.execute_input":"2022-04-21T09:04:23.420281Z","iopub.status.idle":"2022-04-21T09:04:23.426485Z","shell.execute_reply.started":"2022-04-21T09:04:23.420258Z","shell.execute_reply":"2022-04-21T09:04:23.425376Z"},"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":"2022-04-21T09:04:23.427785Z","iopub.execute_input":"2022-04-21T09:04:23.428144Z","iopub.status.idle":"2022-04-21T09:04:23.443122Z","shell.execute_reply.started":"2022-04-21T09:04:23.428099Z","shell.execute_reply":"2022-04-21T09:04:23.442389Z"},"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":"2022-04-21T09:04:23.444436Z","iopub.execute_input":"2022-04-21T09:04:23.445114Z","iopub.status.idle":"2022-04-21T09:44:35.655652Z","shell.execute_reply.started":"2022-04-21T09:04:23.445077Z","shell.execute_reply":"2022-04-21T09:44:35.653114Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# torch.save\ntorch.save(model.state_dict(), './modetor.pt')","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:44:35.657176Z","iopub.execute_input":"2022-04-21T09:44:35.657557Z","iopub.status.idle":"2022-04-21T09:44:35.818106Z","shell.execute_reply.started":"2022-04-21T09:44:35.657504Z","shell.execute_reply":"2022-04-21T09:44:35.817276Z"},"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":"2022-04-21T09:44:35.819521Z","iopub.execute_input":"2022-04-21T09:44:35.819917Z","iopub.status.idle":"2022-04-21T09:44:35.829861Z","shell.execute_reply.started":"2022-04-21T09:44:35.819873Z","shell.execute_reply":"2022-04-21T09:44:35.829056Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# prediction\npred = predict(0)","metadata":{"execution":{"iopub.status.busy":"2022-04-21T09:44:35.831147Z","iopub.execute_input":"2022-04-21T09:44:35.831682Z","iopub.status.idle":"2022-04-21T09:45:39.289065Z","shell.execute_reply.started":"2022-04-21T09:44:35.831647Z","shell.execute_reply":"2022-04-21T09:45:39.288114Z"},"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":"2022-04-21T09:45:39.290882Z","iopub.execute_input":"2022-04-21T09:45:39.291233Z","iopub.status.idle":"2022-04-21T09:45:39.341204Z","shell.execute_reply.started":"2022-04-21T09:45:39.291186Z","shell.execute_reply":"2022-04-21T09:45:39.340490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}