{"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":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt \nimport seaborn as sns\n\n## Reading train data-files\ntrain = pd.read_csv(\"../input/rsna-2022-cervical-spine-fracture-detection/train.csv\")\ntrain_bound_boxes = pd.read_csv(\"../input/rsna-2022-cervical-spine-fracture-detection/train_bounding_boxes.csv\")","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-10T17:52:02.998558Z","iopub.execute_input":"2022-08-10T17:52:02.998978Z","iopub.status.idle":"2022-08-10T17:52:03.020428Z","shell.execute_reply.started":"2022-08-10T17:52:02.998943Z","shell.execute_reply":"2022-08-10T17:52:03.019543Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Train Dataset Exploration","metadata":{}},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:51:57.959317Z","iopub.execute_input":"2022-08-10T17:51:57.95975Z","iopub.status.idle":"2022-08-10T17:51:57.978127Z","shell.execute_reply.started":"2022-08-10T17:51:57.959709Z","shell.execute_reply":"2022-08-10T17:51:57.977133Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train['StudyInstanceUID'].unique())","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:54:38.765752Z","iopub.execute_input":"2022-08-10T17:54:38.76621Z","iopub.status.idle":"2022-08-10T17:54:38.774731Z","shell.execute_reply.started":"2022-08-10T17:54:38.766172Z","shell.execute_reply":"2022-08-10T17:54:38.77372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:54:51.778299Z","iopub.execute_input":"2022-08-10T17:54:51.778724Z","iopub.status.idle":"2022-08-10T17:54:51.785891Z","shell.execute_reply.started":"2022-08-10T17:54:51.778687Z","shell.execute_reply":"2022-08-10T17:54:51.784668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def relative_freq(var):\n    \n    print('\\n Frequency table of', var, ' \\n')\n    print(round(100*train[var].value_counts() / train.shape[0], 2))\n\nrelative_freq('patient_overall')\nrelative_freq('C1')\nrelative_freq('C2')\nrelative_freq('C3')\nrelative_freq('C4')\nrelative_freq('C5')\nrelative_freq('C6')\nrelative_freq('C7')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:51:28.236253Z","iopub.execute_input":"2022-08-10T17:51:28.23665Z","iopub.status.idle":"2022-08-10T17:51:28.259114Z","shell.execute_reply.started":"2022-08-10T17:51:28.236618Z","shell.execute_reply":"2022-08-10T17:51:28.257724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the above, C-7 is the one with the highest relative frequency. patient_overall and C1-C7 should be related, but I'll check it anyways.","metadata":{}},{"cell_type":"code","source":"from scipy.stats import chi2_contingency\n\ndef chi_square_test(var1, var2):\n    \n    stat, p, dof, expected = chi2_contingency(pd.crosstab(train[var1], train[var2]))\n    prob = 0.95\n    alpha = 1.0 - prob\n    if p <= alpha:\n        return(print(var1, ' and ', var2,  ' are dependent (reject H0)'))\n    else:\n        return(print(var1, ' and ', var2, ' are independent (fail to reject H0)'))\n    \n## Running chi-square tests\nchi_square_test('patient_overall', 'C1')\nchi_square_test('patient_overall', 'C2')\nchi_square_test('patient_overall', 'C3')\nchi_square_test('patient_overall', 'C4')\nchi_square_test('patient_overall', 'C5')\nchi_square_test('patient_overall', 'C6')\nchi_square_test('patient_overall', 'C7')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:51:30.743028Z","iopub.execute_input":"2022-08-10T17:51:30.744241Z","iopub.status.idle":"2022-08-10T17:51:30.827784Z","shell.execute_reply.started":"2022-08-10T17:51:30.744191Z","shell.execute_reply":"2022-08-10T17:51:30.826928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Train Bound Boxes Exploration","metadata":{}},{"cell_type":"code","source":"train_bound_boxes.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:51:41.922765Z","iopub.execute_input":"2022-08-10T17:51:41.923214Z","iopub.status.idle":"2022-08-10T17:51:41.937773Z","shell.execute_reply.started":"2022-08-10T17:51:41.923178Z","shell.execute_reply":"2022-08-10T17:51:41.936454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_bound_boxes.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:55:17.539886Z","iopub.execute_input":"2022-08-10T17:55:17.540381Z","iopub.status.idle":"2022-08-10T17:55:17.547637Z","shell.execute_reply.started":"2022-08-10T17:55:17.540344Z","shell.execute_reply":"2022-08-10T17:55:17.546473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train_bound_boxes['StudyInstanceUID'].unique())","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:53:11.131286Z","iopub.execute_input":"2022-08-10T17:53:11.132238Z","iopub.status.idle":"2022-08-10T17:53:11.14052Z","shell.execute_reply.started":"2022-08-10T17:53:11.132199Z","shell.execute_reply":"2022-08-10T17:53:11.139298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train_bound_boxes['slice_number'].unique())","metadata":{"execution":{"iopub.status.busy":"2022-08-10T17:57:43.113181Z","iopub.execute_input":"2022-08-10T17:57:43.113869Z","iopub.status.idle":"2022-08-10T17:57:43.122147Z","shell.execute_reply.started":"2022-08-10T17:57:43.113824Z","shell.execute_reply":"2022-08-10T17:57:43.120867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Notice that there are 235 StudyInstanceUID unique ids and 458 slice_number. Let's create some initial scatter-plots ","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}