{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nfrom pathlib import Path","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"ls ../input/rsna-intracranial-hemorrhage-detection/","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train = pd.read_csv(\"../input/rsna-intracranial-hemorrhage-detection/stage_1_train.csv\")\nsample = pd.read_csv(\"../input/rsna-intracranial-hemorrhage-detection/stage_1_sample_submission.csv\")\ntrain_images_path_list = list(Path(\"../input/rsna-intracranial-hemorrhage-detection/stage_1_train_images/\").glob(\"*\"))\ntest_images_path_list = list(Path(\"../input/rsna-intracranial-hemorrhage-detection/stage_1_test_images/\").glob(\"*\"))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"display(train.shape)\ndisplay(sample.shape)\n\ntrain['Label'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len(train_images_path_list), len(test_images_path_list)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len(train_images_path_list) * 6","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head(7)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample.head(7)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"* There are 6 Sub-type per image\n* https://www.kaggle.com/c/rsna-intracranial-hemorrhage-detection/overview/hemorrhage-types\n    <img src='https://cdn.discordapp.com/attachments/507208726864855060/623862702955036702/RSNA_Intracranial_Hemorrhage_Detection_Kaggle.png'>\n\nLet's see the label for each sub-type."},{"metadata":{"trusted":true},"cell_type":"code","source":"train['Image ID'] = train['ID'].apply(lambda x: x.split('_')[1])\ntrain['Sub-type'] = train['ID'].apply(lambda x: x.split('_')[2])\ntrain = pd.pivot_table(train, index='Image ID', columns='Sub-type')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.mean()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample['Sub-type'] = sample['ID'].apply(lambda x:x.split('_')[2])\nsample.loc[sample['Sub-type'] == 'any', 'Label'] = train.mean()[0]\nsample.loc[sample['Sub-type'] == 'epidural', 'Label'] = train.mean()[1]\nsample.loc[sample['Sub-type'] == 'intraparenchymal', 'Label'] = train.mean()[2]\nsample.loc[sample['Sub-type'] == 'intraventricular', 'Label'] = train.mean()[3]\nsample.loc[sample['Sub-type'] == 'subarachnoid', 'Label'] = train.mean()[4]\nsample.loc[sample['Sub-type'] == 'subdural', 'Label'] = train.mean()[5]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample = sample.drop('Sub-type', axis=1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample.to_csv('submit.csv', index=False)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample.head()","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":1}