{"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":"markdown","source":"# Imports","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2023-08-07T11:20:47.714683Z","iopub.execute_input":"2023-08-07T11:20:47.715503Z","iopub.status.idle":"2023-08-07T11:20:48.594245Z","shell.execute_reply.started":"2023-08-07T11:20:47.715457Z","shell.execute_reply":"2023-08-07T11:20:48.592735Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Paths","metadata":{}},{"cell_type":"code","source":"BASE_PATH = \"/kaggle/input/rsna-2023-abdominal-trauma-detection\"\nTRAIN_CSV = f\"{BASE_PATH}/train.csv\"","metadata":{"execution":{"iopub.status.busy":"2023-08-07T11:13:19.66801Z","iopub.execute_input":"2023-08-07T11:13:19.668525Z","iopub.status.idle":"2023-08-07T11:13:19.674418Z","shell.execute_reply.started":"2023-08-07T11:13:19.668486Z","shell.execute_reply":"2023-08-07T11:13:19.673036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data","metadata":{}},{"cell_type":"code","source":"data = pd.read_csv(TRAIN_CSV)\ndata.head()","metadata":{"execution":{"iopub.status.busy":"2023-08-07T11:29:47.717188Z","iopub.execute_input":"2023-08-07T11:29:47.717636Z","iopub.status.idle":"2023-08-07T11:29:47.745507Z","shell.execute_reply.started":"2023-08-07T11:29:47.71759Z","shell.execute_reply":"2023-08-07T11:29:47.744535Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The dataset appears to contain information about different patients and their health statuses for various organs, such as the bowel, kidneys, liver, and spleen. The features represent whether the organ is healthy, has a low or high injury, or any extravasation (leakage of fluid).\n\nHere is an overview of the columns:\n\n- patient_id: Identifier for each patient.\n- bowel_healthy, bowel_injury: Indicators for the health of the bowel.\n- extravasation_healthy, extravasation_injury: Indicators for the presence of extravasation.\n- kidney_healthy, kidney_low, kidney_high: Indicators for the health of the kidneys.\n- liver_healthy, liver_low, liver_high: Indicators for the health of the liver.\n- spleen_healthy, spleen_low, spleen_high: Indicators for the health of the spleen.\n- any_injury: Indicator for any type of injury.","metadata":{}},{"cell_type":"code","source":"# Checking the summary statistics of the dataset\nsummary_statistics = data.describe()\n\nsummary_statistics.iloc[1]","metadata":{"execution":{"iopub.status.busy":"2023-08-07T11:33:04.324521Z","iopub.execute_input":"2023-08-07T11:33:04.325075Z","iopub.status.idle":"2023-08-07T11:33:04.382Z","shell.execute_reply.started":"2023-08-07T11:33:04.325034Z","shell.execute_reply":"2023-08-07T11:33:04.380598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"| Category | Healthy | Injury | Low | High |\n| :--: | :--: | :--: | :--: | :--: |\n| Bowel | 98% | 2% | - | - |\n| Extravasation | 93% | 7% | - | - |\n| Kidney | 95% | - | 3% | 2% |\n| Liver | 89% | - | 8% | 1% |\n| Spleen | 88% | - | 6% | 4% |\n\n27% are injured!","metadata":{}},{"cell_type":"code","source":"# Checking for missing values\nmissing_values = data.isnull().sum()\n\nmissing_values","metadata":{"execution":{"iopub.status.busy":"2023-08-07T11:17:16.032163Z","iopub.execute_input":"2023-08-07T11:17:16.032633Z","iopub.status.idle":"2023-08-07T11:17:16.042834Z","shell.execute_reply.started":"2023-08-07T11:17:16.032577Z","shell.execute_reply":"2023-08-07T11:17:16.041666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"No missing values makes it easier for us!","metadata":{}},{"cell_type":"code","source":"# Selecting columns related to the health of organs\nhealth_columns = [\n    \"bowel_healthy\", \"extravasation_healthy\", \"kidney_healthy\", \n    \"liver_healthy\", \"spleen_healthy\",\n]\n\n# Calculating the correlation matrix for the selected columns\ncorrelation_matrix = data[health_columns].corr()\n\n# Plotting the heatmap to visualize the correlations\nplt.figure(figsize=(12, 8))\nsns.heatmap(correlation_matrix, annot=True, cmap=\"YlGnBu\", linewidths=.5)\nplt.title(\"Correlation Heatmap of Organ Health\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-07T11:35:58.037072Z","iopub.execute_input":"2023-08-07T11:35:58.037745Z","iopub.status.idle":"2023-08-07T11:35:58.516695Z","shell.execute_reply.started":"2023-08-07T11:35:58.037704Z","shell.execute_reply":"2023-08-07T11:35:58.515388Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The correlations between different health columns are generally small, indicating that the healthy state of one organ might not be strongly related to the healthy state of other organs.\n\nThere is no strong correlation between any two specific health-related columns, suggesting that the health status of different organs is relatively independent of each other.\n\n","metadata":{}},{"cell_type":"code","source":"# Selecting columns related to the health of organs\ninjury_columns = [\n    \"bowel_injury\", \"extravasation_injury\",\n    \"kidney_low\", \"kidney_high\", \n    \"liver_low\", \"liver_high\",\n    \"spleen_low\", \"spleen_high\",\n    \"any_injury\"\n]\n\n# Calculating the correlation matrix for the selected columns\ncorrelation_matrix = data[injury_columns].corr()\n\n# Plotting the heatmap to visualize the correlations\nplt.figure(figsize=(12, 8))\nsns.heatmap(correlation_matrix, annot=True, cmap=\"YlGnBu\", linewidths=.5)\nplt.title(\"Correlation Heatmap of Organ Injury\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-07T11:38:10.125358Z","iopub.execute_input":"2023-08-07T11:38:10.125892Z","iopub.status.idle":"2023-08-07T11:38:10.822869Z","shell.execute_reply.started":"2023-08-07T11:38:10.12585Z","shell.execute_reply":"2023-08-07T11:38:10.821518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Bowel and Extravasation:\n- **bowel_injury**: This shows a moderate correlation with **any_injury** (0.24) and a smaller correlation with **extravasation_injury** (0.13)\n- **extravasation_injury**: This has a strong correlation with **any_injury** (0.43) and a moderate correlation with **spleen_high** (0.200).\n\nKidney:\n- **kidney_low**: This is moderately correlated with **any_injury** (0.319).\n- **kidney_high**: Similar to **kidney_low**, this is moderately correlated with **any_injury** (0.24).\n\nLiver:\n- **liver_low**: This has a strong correlation with **any_injury** (0.490).\n- **liver_high**: This shows a moderate correlation with **any_injury** (0.232).\n\nSpleen:\n- **spleen_low**: This is moderately correlated with **any_injury** (0.425).\n- **spleen_high**: This shows a moderate correlation with **any_injury** (0.373) and **extravasation_injury** (0.200).\n\nConclusions:\nThe **any_injury** column is moderately to strongly correlated with all other injury columns, suggesting that it may be a summary measure of injury presence across different organs.\n\nThere are some specific correlations between individual injury types, such as the correlation between **extravasation_injury** and **spleen_high**.\n\nThe correlations between the low and high levels of organ injuries (e.g., **kidney_low** and **kidney_high**) are generally lower, indicating that these might be independent conditions.\n\nThe correlation between different organs' injuries is generally low, which might suggest that injuries to different organs occur independently of each other.","metadata":{}}]}