{"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 -q /kaggle/input/keras-cv-core-namex/namex-0.0.7-py3-none-any.whl\n! pip install -q /kaggle/input/keras-cv-core-namex/keras_core-0.1.4-py3-none-any.whl\n! pip install -q /kaggle/input/keras-cv-core-namex/keras_cv-0.6.1-py3-none-any.whl","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-08T15:27:47.332403Z","iopub.execute_input":"2023-10-08T15:27:47.333015Z","iopub.status.idle":"2023-10-08T15:29:44.488728Z","shell.execute_reply.started":"2023-10-08T15:27:47.332918Z","shell.execute_reply":"2023-10-08T15:29:44.487124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"INPUT_MODEL_PATH = '/kaggle/input/rsna-3-model-epoch-2-dense-16/rsna-resnet50.keras'\nWORKING_MODEL_PATH = '/kaggle/working/rsna-resnet50.keras'\nSTRIDE = 3","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:29:44.491031Z","iopub.execute_input":"2023-10-08T15:29:44.491401Z","iopub.status.idle":"2023-10-08T15:29:44.496516Z","shell.execute_reply.started":"2023-10-08T15:29:44.49137Z","shell.execute_reply":"2023-10-08T15:29:44.495356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\n\nclass Config:\n    \n    IMAGE_SIZE = [256, 256]\n    RESIZE_DIM = 256\n    BATCH_SIZE = 64\n    AUTOTUNE = tf.data.AUTOTUNE\n    TARGET_COLS  = [\"bowel_healthy\", \"bowel_injury\", \"extravasation_healthy\",\n                   \"extravasation_injury\", \"kidney_healthy\", \"kidney_low\",\n                   \"kidney_high\", \"liver_healthy\", \"liver_low\", \"liver_high\",\n                   \"spleen_healthy\", \"spleen_low\", \"spleen_high\"]\n\nconfig = Config()","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:29:44.497788Z","iopub.execute_input":"2023-10-08T15:29:44.498172Z","iopub.status.idle":"2023-10-08T15:29:54.50941Z","shell.execute_reply.started":"2023-10-08T15:29:44.498144Z","shell.execute_reply":"2023-10-08T15:29:54.508255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nos.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\nimport keras_core as keras\nimport keras_cv","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:29:54.511569Z","iopub.execute_input":"2023-10-08T15:29:54.512192Z","iopub.status.idle":"2023-10-08T15:30:00.016108Z","shell.execute_reply.started":"2023-10-08T15:29:54.512159Z","shell.execute_reply":"2023-10-08T15:30:00.015015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! cp {INPUT_MODEL_PATH} ./\n\nmodel = keras.models.load_model(WORKING_MODEL_PATH)\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:00.017635Z","iopub.execute_input":"2023-10-08T15:30:00.018522Z","iopub.status.idle":"2023-10-08T15:30:21.222474Z","shell.execute_reply.started":"2023-10-08T15:30:00.018487Z","shell.execute_reply":"2023-10-08T15:30:21.221287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings\nwarnings.simplefilter('ignore')\n\nimport pandas as pd\n\npd.set_option('display.max_columns', None)","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.223807Z","iopub.execute_input":"2023-10-08T15:30:21.224197Z","iopub.status.idle":"2023-10-08T15:30:21.22949Z","shell.execute_reply.started":"2023-10-08T15:30:21.224168Z","shell.execute_reply":"2023-10-08T15:30:21.228403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_series_meta = pd.read_csv('/kaggle/input/rsna-2023-abdominal-trauma-detection/test_series_meta.csv')","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.231021Z","iopub.execute_input":"2023-10-08T15:30:21.231461Z","iopub.status.idle":"2023-10-08T15:30:21.255105Z","shell.execute_reply.started":"2023-10-08T15:30:21.231423Z","shell.execute_reply":"2023-10-08T15:30:21.254205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_series_meta['test_images_path'] = '/kaggle/input/rsna-2023-abdominal-trauma-detection/test_images/' +  \\\n    test_series_meta.patient_id.astype(str) + '/' + \\\n    test_series_meta.series_id.astype(str)","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.25612Z","iopub.execute_input":"2023-10-08T15:30:21.256928Z","iopub.status.idle":"2023-10-08T15:30:21.270664Z","shell.execute_reply.started":"2023-10-08T15:30:21.2569Z","shell.execute_reply":"2023-10-08T15:30:21.269544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_series_meta_paths = test_series_meta.test_images_path.tolist()","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.271918Z","iopub.execute_input":"2023-10-08T15:30:21.272343Z","iopub.status.idle":"2023-10-08T15:30:21.28729Z","shell.execute_reply.started":"2023-10-08T15:30:21.272303Z","shell.execute_reply":"2023-10-08T15:30:21.286036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tqdm import tqdm\nfrom glob import glob\n\n\nte_paths = []\n\nfor test_series_meta_path in tqdm(test_series_meta_paths):\n    \n    te_paths += sorted(glob(os.path.join(test_series_meta_path, '*dcm')))[::STRIDE]","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.292342Z","iopub.execute_input":"2023-10-08T15:30:21.292742Z","iopub.status.idle":"2023-10-08T15:30:21.318194Z","shell.execute_reply.started":"2023-10-08T15:30:21.292709Z","shell.execute_reply":"2023-10-08T15:30:21.317236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.DataFrame(te_paths, columns=['dicom_path'])","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.319526Z","iopub.execute_input":"2023-10-08T15:30:21.31981Z","iopub.status.idle":"2023-10-08T15:30:21.32523Z","shell.execute_reply.started":"2023-10-08T15:30:21.319787Z","shell.execute_reply":"2023-10-08T15:30:21.324371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"TEMP_IMAGE_DIR = '/temp/dataset/rsna'","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.326491Z","iopub.execute_input":"2023-10-08T15:30:21.326858Z","iopub.status.idle":"2023-10-08T15:30:21.339619Z","shell.execute_reply.started":"2023-10-08T15:30:21.326831Z","shell.execute_reply":"2023-10-08T15:30:21.338287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['patient_id'] = test_df.dicom_path.map(lambda x: x.split('/')[-3]).astype(int)\ntest_df['series_id'] = test_df.dicom_path.map(lambda x: x.split('/')[-2]).astype(int)\ntest_df['instance_number'] = test_df.dicom_path.map(lambda x: x.split('/')[-1].replace('.dcm', '')).astype(int)\ntest_df['image_path'] = f'{TEMP_IMAGE_DIR}/test_images/' + \\\n    test_df.patient_id.astype(str) + '/' + \\\n    test_df.series_id.astype(str) + '/' + \\\n    test_df.instance_number.astype(str) + '.png'","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.341088Z","iopub.execute_input":"2023-10-08T15:30:21.341634Z","iopub.status.idle":"2023-10-08T15:30:21.361397Z","shell.execute_reply.started":"2023-10-08T15:30:21.341593Z","shell.execute_reply":"2023-10-08T15:30:21.360254Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!rm -r {TEMP_IMAGE_DIR}\n\nos.makedirs(f'{TEMP_IMAGE_DIR}/test_images', exist_ok=True)","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:21.363805Z","iopub.execute_input":"2023-10-08T15:30:21.364242Z","iopub.status.idle":"2023-10-08T15:30:22.533475Z","shell.execute_reply.started":"2023-10-08T15:30:21.364203Z","shell.execute_reply":"2023-10-08T15:30:22.532157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pydicom\nimport numpy as np\nimport cv2\n\ndef standardize_pixel_array(dcm):\n    \n    pixel_array = dcm.pixel_array\n    \n    if dcm.PixelRepresentation == 1:\n        bit_shift = dcm.BitsAllocated - dcm.BitsStored\n        dtype = pixel_array.dtype \n        new_array = (pixel_array << bit_shift).astype(dtype) >>  bit_shift\n        pixel_array = pydicom.pixel_data_handlers.util.apply_modality_lut(new_array, dcm)\n        \n    return pixel_array\n\ndef read_xray(path, fix_monochrome=True):\n    \n    dicom = pydicom.dcmread(path)\n    data = standardize_pixel_array(dicom)\n    data = data - np.min(data)\n    data = data / (np.max(data) + 1e-5)\n    \n    if fix_monochrome and dicom.PhotometricInterpretation == \"MONOCHROME1\":\n        data = 1.0 - data\n        \n    return data\n\ndef resize_and_save(file_path):\n    \n    img = read_xray(file_path)\n    h, w = img.shape[:2]\n    img = cv2.resize(img, (config.RESIZE_DIM, config.RESIZE_DIM), cv2.INTER_LINEAR)\n    img = (img * 255).astype(np.uint8)\n    \n    sub_path = file_path.split(\"/\",4)[-1].split(\".dcm\")[0] + \".png\"\n    infos = sub_path.split(\"/\")\n    \n    pid = infos[-3]\n    sid = infos[-2]\n    iid = infos[-1]; iid = iid.replace(\".png\",\"\")\n    new_path = os.path.join(TEMP_IMAGE_DIR, sub_path)\n    os.makedirs(new_path.rsplit(\"/\",1)[0], exist_ok=True)\n    cv2.imwrite(new_path, img)\n    \n    return","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:22.536136Z","iopub.execute_input":"2023-10-08T15:30:22.536591Z","iopub.status.idle":"2023-10-08T15:30:22.674216Z","shell.execute_reply.started":"2023-10-08T15:30:22.536549Z","shell.execute_reply":"2023-10-08T15:30:22.673305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from joblib import Parallel, delayed\nimport gc\n\n\nfile_paths = test_df.dicom_path.tolist()\nparallel = Parallel(n_jobs=2, backend=\"threading\")(\n    delayed(resize_and_save)(file_path) for file_path in tqdm(file_paths, leave=True, position=0)\n)\n\ndel parallel\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:22.675343Z","iopub.execute_input":"2023-10-08T15:30:22.675613Z","iopub.status.idle":"2023-10-08T15:30:28.152213Z","shell.execute_reply.started":"2023-10-08T15:30:22.67559Z","shell.execute_reply":"2023-10-08T15:30:28.151067Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def decode_image(image_path):\n    \n    file_bytes = tf.io.read_file(image_path)\n    img = tf.io.decode_png(file_bytes, channels=3, dtype=tf.uint8)\n    img = tf.image.resize(img, config.IMAGE_SIZE, method='bilinear')\n    img = tf.cast(img, tf.float32) / 255.0\n    \n    return img","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:28.154131Z","iopub.execute_input":"2023-10-08T15:30:28.154471Z","iopub.status.idle":"2023-10-08T15:30:28.160392Z","shell.execute_reply.started":"2023-10-08T15:30:28.154442Z","shell.execute_reply":"2023-10-08T15:30:28.159077Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def build_dataset(image_paths):\n    \n    ds = (tf.data.Dataset.from_tensor_slices(image_paths)\n          .map(decode_image, num_parallel_calls=config.AUTOTUNE)\n          .shuffle(config.BATCH_SIZE * 10)\n          .batch(config.BATCH_SIZE)\n          .prefetch(config.AUTOTUNE))\n    \n    return ds","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:28.161853Z","iopub.execute_input":"2023-10-08T15:30:28.163146Z","iopub.status.idle":"2023-10-08T15:30:28.174663Z","shell.execute_reply.started":"2023-10-08T15:30:28.163101Z","shell.execute_reply":"2023-10-08T15:30:28.173476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"temp_paths = test_df.image_path.tolist()\n\nds = build_dataset(temp_paths)\nimages = next(iter(ds))\n\nimages.shape","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:28.176424Z","iopub.execute_input":"2023-10-08T15:30:28.176796Z","iopub.status.idle":"2023-10-08T15:30:28.39783Z","shell.execute_reply.started":"2023-10-08T15:30:28.176764Z","shell.execute_reply":"2023-10-08T15:30:28.396677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"patient_ids = test_df.patient_id.unique()\npatient_ids","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:28.399535Z","iopub.execute_input":"2023-10-08T15:30:28.400573Z","iopub.status.idle":"2023-10-08T15:30:28.410541Z","shell.execute_reply.started":"2023-10-08T15:30:28.400541Z","shell.execute_reply":"2023-10-08T15:30:28.409358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"patient_preds = np.zeros(\n    shape=(len(patient_ids), 2*2 + 3*3),\n    dtype='float32'\n)\n\npatient_preds.shape","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:28.412135Z","iopub.execute_input":"2023-10-08T15:30:28.412694Z","iopub.status.idle":"2023-10-08T15:30:28.428288Z","shell.execute_reply.started":"2023-10-08T15:30:28.412654Z","shell.execute_reply":"2023-10-08T15:30:28.427013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def post_proc(pred):\n    \n    proc_pred = np.empty((pred.shape[0], 2*2 + 3*3), dtype='float32')\n    \n    proc_pred[:, 0] = pred[:, 0]\n    proc_pred[:, 1] = 1 - proc_pred[:, 0]\n    proc_pred[:, 2] = pred[:, 1]\n    proc_pred[:, 3] = 1 - proc_pred[:, 2]\n    \n    proc_pred[:, 4:7] = pred[:, 2:5]\n    proc_pred[:, 7:10] = pred[:, 5:8]\n    proc_pred[:, 10:13] = pred[:, 8:11]\n    \n    return proc_pred","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:28.429968Z","iopub.execute_input":"2023-10-08T15:30:28.430468Z","iopub.status.idle":"2023-10-08T15:30:28.440887Z","shell.execute_reply.started":"2023-10-08T15:30:28.430433Z","shell.execute_reply":"2023-10-08T15:30:28.440032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i, p_id in tqdm(enumerate(patient_ids), total=len(patient_ids)):\n    \n    patient_df = test_df.query(f'patient_id=={p_id}')\n    \n    patient_paths = patient_df.image_path.tolist()\n    \n    dataset_test = build_dataset(patient_paths)\n    \n    pred = model.predict(dataset_test)\n    \n    pred = np.concatenate(pred, axis=-1).astype('float32')\n    \n    pred = pred[:len(patient_paths)]\n    \n    pred = np.mean(pred.reshape(1, len(patient_paths), 11), axis=0)\n    \n    pred = np.max(pred, axis=0, keepdims=True)\n    \n    patient_preds[i, :] += post_proc(pred)[0]\n    \n    del patient_df, patient_paths, pred\n    gc.collect()","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:28.441697Z","iopub.execute_input":"2023-10-08T15:30:28.442015Z","iopub.status.idle":"2023-10-08T15:30:34.741387Z","shell.execute_reply.started":"2023-10-08T15:30:28.441975Z","shell.execute_reply":"2023-10-08T15:30:34.740312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"! rm -rf {WORKING_MODEL_PATH}","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:34.743657Z","iopub.execute_input":"2023-10-08T15:30:34.744439Z","iopub.status.idle":"2023-10-08T15:30:35.975412Z","shell.execute_reply.started":"2023-10-08T15:30:34.744397Z","shell.execute_reply":"2023-10-08T15:30:35.974011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_df = pd.DataFrame({'patient_id': patient_ids})\npred_df[config.TARGET_COLS] = patient_preds.astype('float32')","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:35.977379Z","iopub.execute_input":"2023-10-08T15:30:35.978369Z","iopub.status.idle":"2023-10-08T15:30:35.989532Z","shell.execute_reply.started":"2023-10-08T15:30:35.978334Z","shell.execute_reply":"2023-10-08T15:30:35.988458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df = pd.read_csv('/kaggle/input/rsna-2023-abdominal-trauma-detection/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:35.991202Z","iopub.execute_input":"2023-10-08T15:30:35.991716Z","iopub.status.idle":"2023-10-08T15:30:36.01369Z","shell.execute_reply.started":"2023-10-08T15:30:35.991685Z","shell.execute_reply":"2023-10-08T15:30:36.01239Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df = sub_df[['patient_id']]","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.015494Z","iopub.execute_input":"2023-10-08T15:30:36.016241Z","iopub.status.idle":"2023-10-08T15:30:36.02463Z","shell.execute_reply.started":"2023-10-08T15:30:36.016195Z","shell.execute_reply":"2023-10-08T15:30:36.023571Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df = sub_df.merge(pred_df, on='patient_id', how='left')\nsub_df","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.031685Z","iopub.execute_input":"2023-10-08T15:30:36.033014Z","iopub.status.idle":"2023-10-08T15:30:36.082607Z","shell.execute_reply.started":"2023-10-08T15:30:36.03291Z","shell.execute_reply":"2023-10-08T15:30:36.081374Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_3_v4_0_72_bh = (0.9715511 + 0.97249544 + 0.97217387) / 3\nsub_3_v4_0_72_bi = (0.119351186 + 0.11840691 + 0.11872844) / 3\n\nsub_3_v4_0_72_eh = (0.85178125 + 0.8577557 + 0.86438906) / 3\nsub_3_v4_0_72_ei = (1.1228604 + 1.116886 + 1.1102526) / 3\n\nsub_3_v4_0_72_kh = (0.9868032 + 0.9882836 + 0.98775434) / 3\nsub_3_v4_0_72_kl = (0.019482968 + 0.01871935 + 0.019067239) / 3\nsub_3_v4_0_72_khi = (0.029274637 + 0.02855783 + 0.028739242) / 3\n\nsub_3_v4_0_72_lh = (0.95199186 + 0.95849854 + 0.95672786) / 3\nsub_3_v4_0_72_ll = (0.11406416 + 0.107877865 + 0.109601125) / 3\nsub_3_v4_0_72_lhi = (0.006555892 + 0.00623554 + 0.006282879) / 3\n\nsub_3_v4_0_72_sh = (0.8589604 + 0.8723246 + 0.8801043) / 3\nsub_3_v4_0_72_sl = (0.13658747 + 0.12648895 + 0.11792068) / 3\nsub_3_v4_0_72_shi = (0.024457881 + 0.02119218 + 0.021980718) / 3","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.084406Z","iopub.execute_input":"2023-10-08T15:30:36.085473Z","iopub.status.idle":"2023-10-08T15:30:36.09448Z","shell.execute_reply.started":"2023-10-08T15:30:36.085423Z","shell.execute_reply":"2023-10-08T15:30:36.093112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_3_0e_v3_0_71_bh = (0.97139734 + 0.9701567 + 0.9712107) / 3\nsub_3_0e_v3_0_71_bi = (0.119504966 + 0.1207456 + 0.119691595) / 3\n\nsub_3_0e_v3_0_71_eh = (0.86158264 + 0.83267385 + 0.8499667) / 3\nsub_3_0e_v3_0_71_ei = (1.113059 + 1.1419679 + 1.124675) / 3\n\nsub_3_0e_v3_0_71_kh = (0.9850477 + 0.9816301 + 0.98485327) / 3\nsub_3_0e_v3_0_71_kl = (0.020285565 + 0.021340264 + 0.020180132) / 3\nsub_3_0e_v3_0_71_khi = (0.030227503 + 0.032590434 + 0.030527368) / 3\n\nsub_3_0e_v3_0_71_lh = (0.9362427 + 0.92229563 + 0.93130445) / 3\nsub_3_0e_v3_0_71_ll = (0.1281492 + 0.1404337 + 0.13274148) / 3\nsub_3_0e_v3_0_71_lhi = (0.008220032 + 0.009882554 + 0.008565985) / 3\n\nsub_3_0e_v3_0_71_sh = (0.8639108 + 0.8434525 + 0.8563023) / 3\nsub_3_0e_v3_0_71_sl = (0.12819876 + 0.14538784 + 0.13512734) / 3\nsub_3_0e_v3_0_71_shi = (0.027896179 + 0.031165408 + 0.028576097) / 3","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.096811Z","iopub.execute_input":"2023-10-08T15:30:36.097322Z","iopub.status.idle":"2023-10-08T15:30:36.109656Z","shell.execute_reply.started":"2023-10-08T15:30:36.097279Z","shell.execute_reply":"2023-10-08T15:30:36.108571Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_1_v38_0_65_bh = 0.85884091817604\nsub_1_v38_0_65_bi = 0.160680692723228\n\nsub_1_v38_0_65_eh = 0.932091000158881 \nsub_1_v38_0_65_ei = 1.25710163012393\n\nsub_1_v38_0_65_kh = 0.918692032570702 \nsub_1_v38_0_65_kl = 0.102806880838894 \nsub_1_v38_0_65_khi = 0.161160910073085 \n\nsub_1_v38_0_65_lh = 0.843760773689228\nsub_1_v38_0_65_ll = 0.186034143628853 \nsub_1_v38_0_65_lhi = 0.209466271369558 \n\nsub_1_v38_0_65_sh = 0.861551602446775\nsub_1_v38_0_65_sl = 0.156405976485542 \nsub_1_v38_0_65_shi = 0.137774939307277 ","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.111347Z","iopub.execute_input":"2023-10-08T15:30:36.112063Z","iopub.status.idle":"2023-10-08T15:30:36.129489Z","shell.execute_reply.started":"2023-10-08T15:30:36.112019Z","shell.execute_reply":"2023-10-08T15:30:36.127971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.bowel_healthy = sub_df.bowel_healthy * 0.6 + sub_3_v4_0_72_bh * 0.1 + \\\n    sub_3_0e_v3_0_71_bh * 0.1 + sub_1_v38_0_65_bh * 0.2\nsub_df.bowel_injury = sub_df.bowel_injury * 0.6 + sub_3_v4_0_72_bi * 0.1 + \\\n    sub_3_0e_v3_0_71_bi * 0.1 + sub_1_v38_0_65_bi * 0.2\n\nsub_df.extravasation_healthy = sub_df.extravasation_healthy * 0.6 + sub_3_v4_0_72_eh * 0.1 + \\\n    sub_3_0e_v3_0_71_eh * 0.1 + sub_1_v38_0_65_eh * 0.2\nsub_df.extravasation_injury = sub_df.extravasation_injury * 0.6 + sub_3_v4_0_72_ei * 0.1 + \\\n    sub_3_0e_v3_0_71_ei * 0.1 + sub_1_v38_0_65_ei * 0.2\n\nsub_df.kidney_healthy = sub_df.kidney_healthy * 0.6 + sub_3_v4_0_72_kh * 0.1 + \\\n    sub_3_0e_v3_0_71_kh * 0.1 + sub_1_v38_0_65_kh * 0.2\nsub_df.kidney_low = sub_df.kidney_low * 0.6 + sub_3_v4_0_72_kl * 0.1 + \\\n    sub_3_0e_v3_0_71_kl * 0.1 + sub_1_v38_0_65_kl * 0.2\nsub_df.kidney_high = sub_df.kidney_high * 0.6 + sub_3_v4_0_72_khi * 0.1 + \\\n    sub_3_0e_v3_0_71_khi * 0.1 + sub_1_v38_0_65_khi * 0.2\n\nsub_df.liver_healthy = sub_df.liver_healthy * 0.6 + sub_3_v4_0_72_lh * 0.1 + \\\n    sub_3_0e_v3_0_71_lh * 0.1 + sub_1_v38_0_65_lh * 0.2\nsub_df.liver_low = sub_df.liver_low * 0.6 + sub_3_v4_0_72_ll * 0.1 + \\\n    sub_3_0e_v3_0_71_ll * 0.1 + sub_1_v38_0_65_ll * 0.2\nsub_df.liver_high = sub_df.liver_high * 0.6 + sub_3_v4_0_72_lhi * 0.1 + \\\n    sub_3_0e_v3_0_71_lhi * 0.1 + sub_1_v38_0_65_lhi * 0.2\n\nsub_df.spleen_healthy = sub_df.spleen_healthy * 0.6 + sub_3_v4_0_72_sh * 0.1 + \\\n    sub_3_0e_v3_0_71_sh * 0.1 + sub_1_v38_0_65_sh * 0.2\nsub_df.spleen_low = sub_df.spleen_low * 0.6 + sub_3_v4_0_72_sl * 0.1 + \\\n    sub_3_0e_v3_0_71_sl * 0.1 + sub_1_v38_0_65_sl * 0.2\nsub_df.spleen_high = sub_df.spleen_high * 0.6 + sub_3_v4_0_72_shi * 0.1 + \\\n    sub_3_0e_v3_0_71_shi * 0.1 + sub_1_v38_0_65_shi * 0.2","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.130628Z","iopub.execute_input":"2023-10-08T15:30:36.131112Z","iopub.status.idle":"2023-10-08T15:30:36.158447Z","shell.execute_reply.started":"2023-10-08T15:30:36.131072Z","shell.execute_reply":"2023-10-08T15:30:36.157421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.159516Z","iopub.execute_input":"2023-10-08T15:30:36.160401Z","iopub.status.idle":"2023-10-08T15:30:36.178107Z","shell.execute_reply.started":"2023-10-08T15:30:36.160371Z","shell.execute_reply":"2023-10-08T15:30:36.177051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv('/kaggle/working/submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-10-08T15:30:36.180403Z","iopub.execute_input":"2023-10-08T15:30:36.181182Z","iopub.status.idle":"2023-10-08T15:30:36.204257Z","shell.execute_reply.started":"2023-10-08T15:30:36.181137Z","shell.execute_reply":"2023-10-08T15:30:36.203031Z"},"trusted":true},"execution_count":null,"outputs":[]}]}