{"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":"### Importing Libraries","metadata":{}},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-08-08T08:12:20.252746Z","iopub.execute_input":"2023-08-08T08:12:20.254016Z","iopub.status.idle":"2023-08-08T08:12:20.260105Z","shell.execute_reply.started":"2023-08-08T08:12:20.253962Z","shell.execute_reply":"2023-08-08T08:12:20.258822Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Loading The Train Dataset","metadata":{}},{"cell_type":"code","source":"data = pd.read_csv(\"/kaggle/input/rsna-2023-abdominal-trauma-detection/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.266935Z","iopub.execute_input":"2023-08-08T08:12:20.267387Z","iopub.status.idle":"2023-08-08T08:12:20.291358Z","shell.execute_reply.started":"2023-08-08T08:12:20.26735Z","shell.execute_reply":"2023-08-08T08:12:20.289785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Dataset Insights","metadata":{}},{"cell_type":"code","source":"data.head(5)","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.368005Z","iopub.execute_input":"2023-08-08T08:12:20.368429Z","iopub.status.idle":"2023-08-08T08:12:20.385111Z","shell.execute_reply.started":"2023-08-08T08:12:20.368394Z","shell.execute_reply":"2023-08-08T08:12:20.383712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.tail(5)","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.388292Z","iopub.execute_input":"2023-08-08T08:12:20.390157Z","iopub.status.idle":"2023-08-08T08:12:20.406004Z","shell.execute_reply.started":"2023-08-08T08:12:20.390106Z","shell.execute_reply":"2023-08-08T08:12:20.404827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.407467Z","iopub.execute_input":"2023-08-08T08:12:20.407937Z","iopub.status.idle":"2023-08-08T08:12:20.421232Z","shell.execute_reply.started":"2023-08-08T08:12:20.407895Z","shell.execute_reply":"2023-08-08T08:12:20.420064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.columns","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.476275Z","iopub.execute_input":"2023-08-08T08:12:20.476672Z","iopub.status.idle":"2023-08-08T08:12:20.485272Z","shell.execute_reply.started":"2023-08-08T08:12:20.476641Z","shell.execute_reply":"2023-08-08T08:12:20.483892Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.describe()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.490968Z","iopub.execute_input":"2023-08-08T08:12:20.491354Z","iopub.status.idle":"2023-08-08T08:12:20.55254Z","shell.execute_reply.started":"2023-08-08T08:12:20.491322Z","shell.execute_reply":"2023-08-08T08:12:20.551386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Handling Missing Values","metadata":{}},{"cell_type":"code","source":"data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.554277Z","iopub.execute_input":"2023-08-08T08:12:20.555433Z","iopub.status.idle":"2023-08-08T08:12:20.564027Z","shell.execute_reply.started":"2023-08-08T08:12:20.555394Z","shell.execute_reply":"2023-08-08T08:12:20.562778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Visualization","metadata":{}},{"cell_type":"code","source":"# Selecting columns related to the low-healthly organs\nlow_health_columns = [\n    \"kidney_low\", \"liver_low\", \"spleen_low\",\n]\n\n# Accessing columns from the DataFrame and calculating the correlation matrix\ncorrelation_matrix = data[low_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 Low Healthly Organs\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.576077Z","iopub.execute_input":"2023-08-08T08:12:20.576463Z","iopub.status.idle":"2023-08-08T08:12:20.902342Z","shell.execute_reply.started":"2023-08-08T08:12:20.576432Z","shell.execute_reply":"2023-08-08T08:12:20.901127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"columns = [\"kidney_low\", \"liver_low\", \"spleen_low\"]\n\n# Create a bar plot\nplt.figure(figsize=(10, 6))\nsns.barplot(data=data[columns])\nplt.title(\"Bar Plot of Low Organ Columns\")\nplt.xlabel(\"Columns\")\nplt.ylabel(\"Values\")\nplt.legend(labels=columns)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:20.904914Z","iopub.execute_input":"2023-08-08T08:12:20.905446Z","iopub.status.idle":"2023-08-08T08:12:21.358778Z","shell.execute_reply.started":"2023-08-08T08:12:20.905403Z","shell.execute_reply":"2023-08-08T08:12:21.35766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Selecting columns related to the healthly 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 Healthly Organs\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:21.360265Z","iopub.execute_input":"2023-08-08T08:12:21.360597Z","iopub.status.idle":"2023-08-08T08:12:21.766395Z","shell.execute_reply.started":"2023-08-08T08:12:21.360569Z","shell.execute_reply":"2023-08-08T08:12:21.765152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The correlations among various health-related columns tend to be modest, implying that the well-being of one organ is not strongly tied to the well-being of others.\n\nThere is limited correlation observed between any two distinct health-related columns, indicating that the vitality of diverse organs appears to be relatively autonomous from one another.","metadata":{}},{"cell_type":"code","source":"health_columns = [\n    \"bowel_healthy\", \"extravasation_healthy\", \"kidney_healthy\", \n    \"liver_healthy\", \"spleen_healthy\",\n]\n\n# Create a bar plot\nplt.figure(figsize=(10, 6))\nsns.barplot(data=data[health_columns])\nplt.title(\"Bar Plot of Healthy Columns\")\nplt.xlabel(\"Columns\")\nplt.ylabel(\"Values\")\n# plt.legend(labels=health_columns)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:21.769016Z","iopub.execute_input":"2023-08-08T08:12:21.769354Z","iopub.status.idle":"2023-08-08T08:12:22.333732Z","shell.execute_reply.started":"2023-08-08T08:12:21.769326Z","shell.execute_reply":"2023-08-08T08:12:22.332554Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Selecting columns related to the high-healthly organs\nhigh_health_columns = [\n    \"kidney_high\", \"liver_high\", \"spleen_high\",\n]\n\n# Calculating the correlation matrix for the selected columns\ncorrelation_matrix = data[high_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 High Healthy Organs\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:22.335083Z","iopub.execute_input":"2023-08-08T08:12:22.335493Z","iopub.status.idle":"2023-08-08T08:12:22.677502Z","shell.execute_reply.started":"2023-08-08T08:12:22.335463Z","shell.execute_reply":"2023-08-08T08:12:22.676082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"high_health_columns = [\n    \"kidney_high\", \"liver_high\", \"spleen_high\",\n]\n\n# Create a bar plot\nplt.figure(figsize=(10, 6))\nsns.barplot(data=data[high_health_columns])\nplt.title(\"Bar Plot of High Healthly Columns\")\nplt.xlabel(\"Columns\")\nplt.ylabel(\"Values\")\n# plt.legend(labels=health_columns)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:22.67898Z","iopub.execute_input":"2023-08-08T08:12:22.67935Z","iopub.status.idle":"2023-08-08T08:12:23.102715Z","shell.execute_reply.started":"2023-08-08T08:12:22.679316Z","shell.execute_reply":"2023-08-08T08:12:23.101872Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"healthly_enjury_columns = [\n    'bowel_healthy', 'extravasation_healthy', 'bowel_injury', 'extravasation_injury'\n]\n\n# Create a bar plot\nplt.figure(figsize=(10, 6))\nsns.barplot(data=data[healthly_enjury_columns])\nplt.title(\"Bar Plot of Healthly VS Enjury Columns\")\nplt.xlabel(\"Columns\")\nplt.ylabel(\"Values\")\n# plt.legend(labels=health_columns)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:23.105021Z","iopub.execute_input":"2023-08-08T08:12:23.105492Z","iopub.status.idle":"2023-08-08T08:12:23.598216Z","shell.execute_reply.started":"2023-08-08T08:12:23.10545Z","shell.execute_reply":"2023-08-08T08:12:23.597017Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Barplot for all \nfor column in data.columns:\n    if column not in ['patient_id', 'any_injury']:\n        plt.figure(figsize=(6, 4))\n        data[column].value_counts().plot(kind='bar')\n        plt.title(f'Bar Plot of {column}')\n        plt.xlabel(column)\n        plt.ylabel('Count')\n        plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-08-08T08:12:23.599581Z","iopub.execute_input":"2023-08-08T08:12:23.599919Z","iopub.status.idle":"2023-08-08T08:12:26.35736Z","shell.execute_reply.started":"2023-08-08T08:12:23.599889Z","shell.execute_reply":"2023-08-08T08:12:26.356196Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Bowel and Extravasation:**\n\nbowel_injury: This shows a moderate correlation with any_injury (0.24) and a smaller correlation with extravasation_injury (0.13)\n\nextravasation_injury: This has a strong correlation with any_injury (0.43) and a moderate correlation with spleen_high (0.200).\n\n**Kidney:**\n\nkidney_low: This is moderately correlated with any_injury (0.319).\nkidney_high: Similar to kidney_low, this is moderately correlated with any_injury (0.24).\n\n**Liver:**\n\nliver_low: This has a strong correlation with any_injury (0.490).\nliver_high: This shows a moderate correlation with any_injury (0.232).\n\n**Spleen:**\n\nspleen_low: This is moderately correlated with any_injury (0.425).\nspleen_high: This shows a moderate correlation with any_injury (0.373) and extravasation_injury (0.200).\n\n\n**Conclusions** \n\nThe any_injury column emerges as moderately to strongly correlated with all other injury columns, suggesting its role as a comprehensive indicator of injury presence across diverse organs.\n\nSpecific correlations between distinct injury types exist, notably the connection between extravasation_injury and spleen_high.\n\nCorrelations between low and high levels of organ injuries, such as kidney_low and kidney_high, generally appear subdued, hinting at potential independence between these conditions.\n\nOverall, the correlations among injuries across different organs tend to be low, implying that injuries to distinct organs are likely to occur independently.","metadata":{}}]}