{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":59093,"databundleVersionId":7469972,"sourceType":"competition"},{"sourceId":171791159,"sourceType":"kernelVersion"},{"sourceId":30346,"sourceType":"modelInstanceVersion","modelInstanceId":25497},{"sourceId":30347,"sourceType":"modelInstanceVersion","modelInstanceId":25498},{"sourceId":30348,"sourceType":"modelInstanceVersion","modelInstanceId":25499},{"sourceId":30350,"sourceType":"modelInstanceVersion","modelInstanceId":25501},{"sourceId":30351,"sourceType":"modelInstanceVersion","modelInstanceId":25502},{"sourceId":30352,"sourceType":"modelInstanceVersion","modelInstanceId":25503},{"sourceId":30354,"sourceType":"modelInstanceVersion","modelInstanceId":25505},{"sourceId":30357,"sourceType":"modelInstanceVersion","modelInstanceId":25506},{"sourceId":30360,"sourceType":"modelInstanceVersion","modelInstanceId":25508},{"sourceId":30428,"sourceType":"modelInstanceVersion","isSourceIdPinned":true,"modelInstanceId":25516}],"dockerImageVersionId":30683,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"%%capture\n!pip install timm transformers audiomentations --no-index --find-links=file:/kaggle/input/hms-pip-wheels3","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:03:56.705344Z","iopub.execute_input":"2024-04-13T11:03:56.705719Z","iopub.status.idle":"2024-04-13T11:04:09.175534Z","shell.execute_reply.started":"2024-04-13T11:03:56.705690Z","shell.execute_reply":"2024-04-13T11:04:09.174384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import sys\nsys.path.append(f'/kaggle/input/hms-3rd-place-weights/pytorch/src/2/configs/configs')\nsys.path.append(f'/kaggle/input/hms-3rd-place-weights/pytorch/src/2/data/data')\nsys.path.append(f'/kaggle/input/hms-3rd-place-weights/pytorch/src/2/models/models')\nsys.path.append(f'/kaggle/input/hms-3rd-place-weights/pytorch/src/2/configs')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-13T11:04:09.177688Z","iopub.execute_input":"2024-04-13T11:04:09.178045Z","iopub.status.idle":"2024-04-13T11:04:09.183959Z","shell.execute_reply.started":"2024-04-13T11:04:09.178012Z","shell.execute_reply":"2024-04-13T11:04:09.182946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport scipy as sp\nimport os\nimport json\nimport sys\nimport importlib\nimport multiprocessing as mp\nimport gc\nfrom tqdm import tqdm\nimport glob\nimport torch\nfrom copy import copy\nfrom torch.cuda.amp import GradScaler, autocast\nfrom torch.utils.data import DataLoader\nfrom sklearn.metrics import  mean_squared_error\n\ntorch.backends.cudnn.benchmark = True","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:09.185187Z","iopub.execute_input":"2024-04-13T11:04:09.185467Z","iopub.status.idle":"2024-04-13T11:04:09.199816Z","shell.execute_reply.started":"2024-04-13T11:04:09.185444Z","shell.execute_reply":"2024-04-13T11:04:09.198963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"COMP_FOLDER = '/kaggle/input/hms-harmful-brain-activity-classification/'\n\ntrain_df = pd.read_csv(COMP_FOLDER + 'train.csv')\ntest_df = pd.read_csv(COMP_FOLDER + 'test.csv')\nsample_submission = pd.read_csv(COMP_FOLDER + 'sample_submission.csv')\n\nEEG_FOLDER = '/kaggle/input/hms-harmful-brain-activity-classification/test_eegs/'\n\nPUBLIC_RUN = len(test_df) == 1\nN_CORES = mp.cpu_count()\nMIXED_PRECISION = False\n\nRAM_CHECK = False\nOOF_CHECK = False\n\n\nDEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'\n\nif PUBLIC_RUN is False:\n    RAM_CHECK = False\n    OOF_CHECK = False\n\nif OOF_CHECK is True:\n    train_df = pd.read_csv('/kaggle/input/hms-aws-bucket/train_folded_17k.csv')\n    EEG_FOLDER = '/kaggle/input/hms-harmful-brain-activity-classification/train_eegs/'\n    test_df = train_df[train_df['fold']==0].copy()\n\n\nif RAM_CHECK is True:\n    train_df = pd.read_csv('/kaggle/input/hms-aws-bucket/train_folded_17k.csv')\n    EEG_FOLDER = '/kaggle/input/hms-harmful-brain-activity-classification/train_eegs/'\n    test_df = train_df[train_df['fold']==0].copy()\n    test_df = test_df.head(2640).copy()\n\nprint(train_df.shape)\nprint(test_df.shape)\n\nTARGETS = ['seizure_vote','lpd_vote','gpd_vote','lrda_vote','grda_vote','other_vote']\nif TARGETS[0] not in test_df.columns:\n    test_df[TARGETS] = 1\n    test_df['eeg_label_offset_seconds'] = 0\n    test_df['spectrogram_label_offset_seconds'] = 0","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:09.202418Z","iopub.execute_input":"2024-04-13T11:04:09.203014Z","iopub.status.idle":"2024-04-13T11:04:09.398177Z","shell.execute_reply.started":"2024-04-13T11:04:09.202960Z","shell.execute_reply":"2024-04-13T11:04:09.397272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_cfg(CFG):\n    cfg = importlib.import_module('default_config')\n    importlib.reload(cfg)\n    cfg = importlib.import_module(CFG)\n    importlib.reload(cfg)\n    cfg = copy(cfg.cfg)\n    cfg.data_dir = COMP_FOLDER\n    cfg.mixed_precision = MIXED_PRECISION\n    cfg.pretrained = False\n    cfg.pretrained_weights = False\n    cfg.offline_inference = True\n    return cfg\n\ndef get_dl(cfg):\n    ds = importlib.import_module(cfg.dataset)\n    importlib.reload(ds)\n    CustomDataset = ds.CustomDataset\n    batch_to_device = ds.batch_to_device\n    test_ds = CustomDataset(test_df, cfg, cfg.val_aug, mode=\"test\")\n    test_dl = DataLoader(test_ds, shuffle=False, batch_size=cfg.batch_size, collate_fn=ds.val_collate_fn, num_workers=N_CORES, pin_memory=True)\n    return test_dl, batch_to_device\n\ndef get_state_dict(sd_fp):\n    sd = torch.load(sd_fp, map_location=\"cpu\")\n    if \"model\" in sd.keys():\n        sd = sd[\"model\"]\n    sd = {k.replace(\"module.\", \"\"):v for k,v in sd.items()}\n    return sd\n\ndef get_nets(cfg,state_dicts,test_ds):\n    model = importlib.import_module(cfg.model)\n    importlib.reload(model)\n    Net = model.Net\n    nets = []\n    for i,state_dict in enumerate(state_dicts):\n        net = Net(cfg).eval().to(DEVICE)\n        print(\"loading dict\")\n        sd = get_state_dict(state_dict)\n        net.load_state_dict(sd, strict=True)\n        net.return_logits = True\n        nets += [net]\n        del sd\n        gc.collect()\n    return nets","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:09.399369Z","iopub.execute_input":"2024-04-13T11:04:09.399659Z","iopub.status.idle":"2024-04-13T11:04:09.411477Z","shell.execute_reply.started":"2024-04-13T11:04:09.399632Z","shell.execute_reply":"2024-04-13T11:04:09.410558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def generate(name = 'cfg_1', weights_dir = './'):\n    cfg = get_cfg(name)\n    cfg.pretrained = False\n    cfg.data_folder = EEG_FOLDER\n    state_dict_fps = sorted(glob.glob(weights_dir, recursive = True))\n    test_dl, batch_to_device = get_dl(cfg)\n    print('\\n'.join(state_dict_fps))\n    nets = get_nets(cfg,state_dict_fps, test_dl.dataset)\n    preds = []\n    with torch.inference_mode():\n        for batch in tqdm(test_dl):\n            batch = batch_to_device(batch,DEVICE)\n            outs = [net(batch) for net in nets]\n            preds += [torch.stack([out['logits'] for out in outs], dim=0).mean(0).cpu()]\n    preds = torch.cat(preds, dim=0).float()\n    print('preds', preds.shape, ', test_df',test_df.shape)\n    gc.collect()\n    torch.cuda.empty_cache()\n    return preds","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:09.412584Z","iopub.execute_input":"2024-04-13T11:04:09.412849Z","iopub.status.idle":"2024-04-13T11:04:09.425762Z","shell.execute_reply.started":"2024-04-13T11:04:09.412826Z","shell.execute_reply":"2024-04-13T11:04:09.424913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS = {}","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:09.426813Z","iopub.execute_input":"2024-04-13T11:04:09.427155Z","iopub.status.idle":"2024-04-13T11:04:09.439743Z","shell.execute_reply.started":"2024-04-13T11:04:09.427129Z","shell.execute_reply":"2024-04-13T11:04:09.439027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_1'] = generate(name = 'cfg_1', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_1/1/cfg_1/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:09.440996Z","iopub.execute_input":"2024-04-13T11:04:09.441506Z","iopub.status.idle":"2024-04-13T11:04:27.332265Z","shell.execute_reply.started":"2024-04-13T11:04:09.441481Z","shell.execute_reply":"2024-04-13T11:04:27.331221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_2a'] = generate(name = 'cfg_2a', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_2a/1/cfg_2a/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:06:10.474128Z","iopub.execute_input":"2024-04-13T11:06:10.474455Z","iopub.status.idle":"2024-04-13T11:06:15.673657Z","shell.execute_reply.started":"2024-04-13T11:06:10.474426Z","shell.execute_reply":"2024-04-13T11:06:15.672583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_2b'] = generate(name = 'cfg_2b', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_2b/1/cfg_2b/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:06:15.676462Z","iopub.execute_input":"2024-04-13T11:06:15.676823Z","iopub.status.idle":"2024-04-13T11:06:20.842860Z","shell.execute_reply.started":"2024-04-13T11:06:15.676792Z","shell.execute_reply":"2024-04-13T11:06:20.841760Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_3'] = generate(name = 'cfg_3', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_3/1/cfg_3/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:27.334586Z","iopub.execute_input":"2024-04-13T11:04:27.334895Z","iopub.status.idle":"2024-04-13T11:04:40.673239Z","shell.execute_reply.started":"2024-04-13T11:04:27.334867Z","shell.execute_reply":"2024-04-13T11:04:40.672189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_4'] = generate(name = 'cfg_4', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_4/1/cfg_4/*/*check*')\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:40.677099Z","iopub.execute_input":"2024-04-13T11:04:40.677399Z","iopub.status.idle":"2024-04-13T11:04:58.841127Z","shell.execute_reply.started":"2024-04-13T11:04:40.677373Z","shell.execute_reply":"2024-04-13T11:04:58.840053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_5a'] = generate(name = 'cfg_5a', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_5a/1/cfg_5a/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:04:58.843592Z","iopub.execute_input":"2024-04-13T11:04:58.843916Z","iopub.status.idle":"2024-04-13T11:05:17.785807Z","shell.execute_reply.started":"2024-04-13T11:04:58.843887Z","shell.execute_reply":"2024-04-13T11:05:17.784725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_5b'] = generate(name = 'cfg_5b', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_5b/1/cfg_5b/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:05:17.788656Z","iopub.execute_input":"2024-04-13T11:05:17.788991Z","iopub.status.idle":"2024-04-13T11:05:34.379983Z","shell.execute_reply.started":"2024-04-13T11:05:17.788952Z","shell.execute_reply":"2024-04-13T11:05:34.378919Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_5c'] = generate(name = 'cfg_5c', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_5c/1/cfg_5c/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:05:34.383298Z","iopub.execute_input":"2024-04-13T11:05:34.383617Z","iopub.status.idle":"2024-04-13T11:05:50.997693Z","shell.execute_reply.started":"2024-04-13T11:05:34.383587Z","shell.execute_reply":"2024-04-13T11:05:50.996351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PREDS['cfg_5d'] = generate(name = 'cfg_5d', weights_dir = f'/kaggle/input/hms-3rd-place-weights/pytorch/cfg_5d/1/cfg_5d/*/*check*')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:05:51.001347Z","iopub.execute_input":"2024-04-13T11:05:51.001683Z","iopub.status.idle":"2024-04-13T11:06:10.468552Z","shell.execute_reply.started":"2024-04-13T11:05:51.001653Z","shell.execute_reply":"2024-04-13T11:06:10.467345Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CLASS_BIAS = [ 0.012535,  0.03458 ,  0.01761 ,  0.05957 , -0.02608 , -0.0982  ]","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:07:07.206137Z","iopub.execute_input":"2024-04-13T11:07:07.206971Z","iopub.status.idle":"2024-04-13T11:07:07.212072Z","shell.execute_reply.started":"2024-04-13T11:07:07.206939Z","shell.execute_reply":"2024-04-13T11:07:07.210847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"WEIGHTS = {'cfg_1': 0.12932,\n 'cfg_2a': 0.14089,\n 'cfg_2b': 0.12269,\n 'cfg_3': 0.1174,\n 'cfg_4': 0.10538,\n 'cfg_5a': 0.0987,\n 'cfg_5b': 0.15285,\n 'cfg_5c': 0.10973,\n 'cfg_5d': 0.09444}","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:07:04.766402Z","iopub.execute_input":"2024-04-13T11:07:04.767173Z","iopub.status.idle":"2024-04-13T11:07:04.772142Z","shell.execute_reply.started":"2024-04-13T11:07:04.767140Z","shell.execute_reply":"2024-04-13T11:07:04.771250Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"assert sorted(PREDS.keys()) == sorted(WEIGHTS.keys())\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:08:17.042931Z","iopub.execute_input":"2024-04-13T11:08:17.043888Z","iopub.status.idle":"2024-04-13T11:08:17.048273Z","shell.execute_reply.started":"2024-04-13T11:08:17.043846Z","shell.execute_reply":"2024-04-13T11:08:17.047319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for k,p in PREDS.items():\n    print(k)\n    print(np.around(p[:3].softmax(1).numpy(), decimals=3))\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:08:26.872465Z","iopub.execute_input":"2024-04-13T11:08:26.873154Z","iopub.status.idle":"2024-04-13T11:08:26.882503Z","shell.execute_reply.started":"2024-04-13T11:08:26.873123Z","shell.execute_reply":"2024-04-13T11:08:26.881468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_weights = sum(list(WEIGHTS.values()))\ntotal_weights","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:09:10.007144Z","iopub.execute_input":"2024-04-13T11:09:10.008137Z","iopub.status.idle":"2024-04-13T11:09:10.015036Z","shell.execute_reply.started":"2024-04-13T11:09:10.008102Z","shell.execute_reply":"2024-04-13T11:09:10.014108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"WEIGHTS = {k:v/sum(list(WEIGHTS.values())) for k,v in WEIGHTS.items()}\nsum(list(WEIGHTS.values()))","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:09:11.330188Z","iopub.execute_input":"2024-04-13T11:09:11.331111Z","iopub.status.idle":"2024-04-13T11:09:11.337551Z","shell.execute_reply.started":"2024-04-13T11:09:11.331077Z","shell.execute_reply":"2024-04-13T11:09:11.336595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for k,v in WEIGHTS.items():\n    print(f'{v:0.3f} {k}')","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:09:12.756771Z","iopub.execute_input":"2024-04-13T11:09:12.757466Z","iopub.status.idle":"2024-04-13T11:09:12.762480Z","shell.execute_reply.started":"2024-04-13T11:09:12.757435Z","shell.execute_reply":"2024-04-13T11:09:12.761496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = torch.stack([(v * WEIGHTS[k]) for k,v in PREDS.items()]).sum(0)\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:09:43.264014Z","iopub.execute_input":"2024-04-13T11:09:43.264895Z","iopub.status.idle":"2024-04-13T11:09:43.271038Z","shell.execute_reply.started":"2024-04-13T11:09:43.264856Z","shell.execute_reply":"2024-04-13T11:09:43.270123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(np.around(preds[:3].numpy(), decimals=3))\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:09:44.694660Z","iopub.execute_input":"2024-04-13T11:09:44.695026Z","iopub.status.idle":"2024-04-13T11:09:44.700985Z","shell.execute_reply.started":"2024-04-13T11:09:44.694997Z","shell.execute_reply":"2024-04-13T11:09:44.699896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"postproc = torch.tensor(CLASS_BIAS).unsqueeze(0)\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:10:04.116948Z","iopub.execute_input":"2024-04-13T11:10:04.117345Z","iopub.status.idle":"2024-04-13T11:10:04.122343Z","shell.execute_reply.started":"2024-04-13T11:10:04.117317Z","shell.execute_reply":"2024-04-13T11:10:04.121279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = preds + postproc\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:10:15.626794Z","iopub.execute_input":"2024-04-13T11:10:15.627503Z","iopub.status.idle":"2024-04-13T11:10:15.631745Z","shell.execute_reply.started":"2024-04-13T11:10:15.627469Z","shell.execute_reply":"2024-04-13T11:10:15.630803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(np.around(preds[:3].numpy(), decimals=3))\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:10:17.030058Z","iopub.execute_input":"2024-04-13T11:10:17.030427Z","iopub.status.idle":"2024-04-13T11:10:17.036301Z","shell.execute_reply.started":"2024-04-13T11:10:17.030400Z","shell.execute_reply":"2024-04-13T11:10:17.035383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = preds.softmax(1).numpy().copy()\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:10:38.036759Z","iopub.execute_input":"2024-04-13T11:10:38.037227Z","iopub.status.idle":"2024-04-13T11:10:38.041727Z","shell.execute_reply.started":"2024-04-13T11:10:38.037197Z","shell.execute_reply":"2024-04-13T11:10:38.040796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = preds / preds.sum(1)[:,None]\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:10:39.238232Z","iopub.execute_input":"2024-04-13T11:10:39.238986Z","iopub.status.idle":"2024-04-13T11:10:39.243401Z","shell.execute_reply.started":"2024-04-13T11:10:39.238945Z","shell.execute_reply":"2024-04-13T11:10:39.242435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(np.around(preds[:3], decimals=3))\n","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:10:40.594142Z","iopub.execute_input":"2024-04-13T11:10:40.594979Z","iopub.status.idle":"2024-04-13T11:10:40.600485Z","shell.execute_reply.started":"2024-04-13T11:10:40.594930Z","shell.execute_reply":"2024-04-13T11:10:40.599511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.DataFrame({'eeg_id': test_df.eeg_id.values})\nsub[TARGETS] = preds\nsub.to_csv('submission.csv',index=False)\nprint('Submission shape',sub.shape)\nsub.head()","metadata":{"execution":{"iopub.status.busy":"2024-04-13T11:11:00.540356Z","iopub.execute_input":"2024-04-13T11:11:00.541097Z","iopub.status.idle":"2024-04-13T11:11:00.564987Z","shell.execute_reply.started":"2024-04-13T11:11:00.541065Z","shell.execute_reply":"2024-04-13T11:11:00.564089Z"},"trusted":true},"execution_count":null,"outputs":[]}]}