{"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":"# 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\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\n'''for dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))'''\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":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-10-10T08:59:10.413213Z","iopub.execute_input":"2021-10-10T08:59:10.413615Z","iopub.status.idle":"2021-10-10T08:59:10.431625Z","shell.execute_reply.started":"2021-10-10T08:59:10.413521Z","shell.execute_reply":"2021-10-10T08:59:10.430984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport sys \nimport json\nimport glob\nimport random\nimport re\nimport collections\nimport time\n\nimport numpy as np\nimport pandas as pd\n'''import pydicom\nimport cv2\nimport matplotlib.pyplot as plt   \nimport seaborn as sns\n\nimport torch\nfrom torch import nn\nfrom torch.utils import data as torch_data\nfrom sklearn import model_selection as sk_model_selection\nfrom torch.nn import functional as torch_functional\n\nfrom sklearn.model_selection import StratifiedKFold\nfrom sklearn.metrics import roc_auc_score\n\nfrom skimage.transform import resize'''","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:59:11.486261Z","iopub.execute_input":"2021-10-10T08:59:11.486552Z","iopub.status.idle":"2021-10-10T08:59:11.493971Z","shell.execute_reply.started":"2021-10-10T08:59:11.486523Z","shell.execute_reply":"2021-10-10T08:59:11.493187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df_list = []\nfor df_i in range(4):\n    path_i = '/kaggle/input/test-submission-sample/test_fold'+str(df_i)+'all_DenseNet121_I256_R42_4ph_ESB_preds.csv'\n    test_df_i = pd.read_csv(path_i)\n    test_df_list.append(test_df_i)","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:59:17.510044Z","iopub.execute_input":"2021-10-10T08:59:17.510600Z","iopub.status.idle":"2021-10-10T08:59:17.535317Z","shell.execute_reply.started":"2021-10-10T08:59:17.510555Z","shell.execute_reply":"2021-10-10T08:59:17.534464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for df in test_df_list:\n    display(df)","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:59:18.378115Z","iopub.execute_input":"2021-10-10T08:59:18.378401Z","iopub.status.idle":"2021-10-10T08:59:18.427087Z","shell.execute_reply.started":"2021-10-10T08:59:18.378374Z","shell.execute_reply":"2021-10-10T08:59:18.426322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test = pd.concat(test_df_list)","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:59:19.191637Z","iopub.execute_input":"2021-10-10T08:59:19.192308Z","iopub.status.idle":"2021-10-10T08:59:19.198324Z","shell.execute_reply.started":"2021-10-10T08:59:19.192263Z","shell.execute_reply":"2021-10-10T08:59:19.197487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:59:20.478943Z","iopub.execute_input":"2021-10-10T08:59:20.480136Z","iopub.status.idle":"2021-10-10T08:59:20.495509Z","shell.execute_reply.started":"2021-10-10T08:59:20.480086Z","shell.execute_reply":"2021-10-10T08:59:20.494893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv('/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/sample_submission.csv') #submission = pd.read_csv(f\"{data_directory}/sample_submission.csv\", index_col=\"BraTS21ID\")\n\nsubmission['MGMT_value'] = 0.0\n\nsubmission\n","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:59:21.290425Z","iopub.execute_input":"2021-10-10T08:59:21.291060Z","iopub.status.idle":"2021-10-10T08:59:21.311288Z","shell.execute_reply.started":"2021-10-10T08:59:21.291013Z","shell.execute_reply":"2021-10-10T08:59:21.310333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for df_i in range(4):\n    test_df_i = test_df_list[df_i]\n    test_df_i.head()\n    print(test_df_i['MGMT_pred'])\n    submission['MGMT_value'] += test_df_i['MGMT_pred']","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:59:22.016444Z","iopub.execute_input":"2021-10-10T08:59:22.017163Z","iopub.status.idle":"2021-10-10T08:59:22.033104Z","shell.execute_reply.started":"2021-10-10T08:59:22.017117Z","shell.execute_reply":"2021-10-10T08:59:22.032205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['MGMT_value'] /= len(test_df_list)\nsubmission","metadata":{"execution":{"iopub.status.busy":"2021-10-10T09:03:08.288709Z","iopub.execute_input":"2021-10-10T09:03:08.289051Z","iopub.status.idle":"2021-10-10T09:03:08.304791Z","shell.execute_reply.started":"2021-10-10T09:03:08.289019Z","shell.execute_reply":"2021-10-10T09:03:08.303843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#BraTSID = submission['BraTS21ID'].values","metadata":{"execution":{"iopub.status.busy":"2021-10-10T09:03:09.256877Z","iopub.execute_input":"2021-10-10T09:03:09.257187Z","iopub.status.idle":"2021-10-10T09:03:09.262183Z","shell.execute_reply.started":"2021-10-10T09:03:09.257149Z","shell.execute_reply":"2021-10-10T09:03:09.261308Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#BraTSID = [str(x).zfill(5) for x in BraTSID]\n#BraTSID","metadata":{"execution":{"iopub.status.busy":"2021-10-10T09:03:11.499091Z","iopub.execute_input":"2021-10-10T09:03:11.499807Z","iopub.status.idle":"2021-10-10T09:03:11.506769Z","shell.execute_reply.started":"2021-10-10T09:03:11.499769Z","shell.execute_reply":"2021-10-10T09:03:11.506254Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#submission['BraTS21ID'] = BraTSID","metadata":{"execution":{"iopub.status.busy":"2021-10-10T09:03:16.372597Z","iopub.execute_input":"2021-10-10T09:03:16.373360Z","iopub.status.idle":"2021-10-10T09:03:16.379206Z","shell.execute_reply.started":"2021-10-10T09:03:16.373290Z","shell.execute_reply":"2021-10-10T09:03:16.378122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2021-10-10T09:03:23.895607Z","iopub.execute_input":"2021-10-10T09:03:23.895913Z","iopub.status.idle":"2021-10-10T09:03:23.909280Z","shell.execute_reply.started":"2021-10-10T09:03:23.895884Z","shell.execute_reply":"2021-10-10T09:03:23.908282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.figure(figsize=(5, 5))\nplt.hist(submission[\"MGMT_value\"])","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:50:14.764884Z","iopub.execute_input":"2021-10-10T08:50:14.76518Z","iopub.status.idle":"2021-10-10T08:50:14.994211Z","shell.execute_reply.started":"2021-10-10T08:50:14.765151Z","shell.execute_reply":"2021-10-10T08:50:14.993356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False) #submission = pd.read_csv(f\"{data_directory}/sample_submission.csv\", index_col=\"BraTS21ID\")\n","metadata":{"execution":{"iopub.status.busy":"2021-10-10T08:50:39.182919Z","iopub.execute_input":"2021-10-10T08:50:39.183208Z","iopub.status.idle":"2021-10-10T08:50:39.192066Z","shell.execute_reply.started":"2021-10-10T08:50:39.18318Z","shell.execute_reply":"2021-10-10T08:50:39.191158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}