{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.18","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"tpu1vmV38","dataSources":[{"sourceId":99552,"databundleVersionId":13190393,"sourceType":"competition"}],"dockerImageVersionId":31091,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        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","trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:01:59.42722Z","iopub.execute_input":"2025-08-07T15:01:59.427591Z","iopub.status.idle":"2025-08-07T15:13:06.874193Z","shell.execute_reply.started":"2025-08-07T15:01:59.427568Z","shell.execute_reply":"2025-08-07T15:13:06.870259Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install plotly","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:50:29.962541Z","iopub.execute_input":"2025-08-07T15:50:29.962856Z","iopub.status.idle":"2025-08-07T15:50:39.512577Z","shell.execute_reply.started":"2025-08-07T15:50:29.96283Z","shell.execute_reply":"2025-08-07T15:50:39.506683Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport plotly.express as px","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:54:17.138322Z","iopub.execute_input":"2025-08-07T15:54:17.138714Z","iopub.status.idle":"2025-08-07T15:54:17.266564Z","shell.execute_reply.started":"2025-08-07T15:54:17.138674Z","shell.execute_reply":"2025-08-07T15:54:17.261695Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"The RSNA Intracranial Aneurysm Detection dataset is part of a medical imaging challenge hosted by the Radiological Society of North America (RSNA), focusing on the automatic detection of intracranial aneurysms (IAs) using 3D CT angiography (CTA) scans.\n\n**🧠 What it's about:**\nIntracranial aneurysms are abnormal bulges or ballooning in the walls of blood vessels in the brain. They are potentially life-threatening if they rupture. Early and accurate detection is critical, but it's a complex task even for experienced radiologists.","metadata":{}},{"cell_type":"code","source":"df=pd.read_csv('/kaggle/input/rsna-intracranial-aneurysm-detection/train.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:13:15.917871Z","iopub.execute_input":"2025-08-07T15:13:15.918143Z","iopub.status.idle":"2025-08-07T15:13:15.950431Z","shell.execute_reply.started":"2025-08-07T15:13:15.918119Z","shell.execute_reply":"2025-08-07T15:13:15.946298Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:13:19.057205Z","iopub.execute_input":"2025-08-07T15:13:19.057477Z","iopub.status.idle":"2025-08-07T15:13:19.093686Z","shell.execute_reply.started":"2025-08-07T15:13:19.057453Z","shell.execute_reply":"2025-08-07T15:13:19.090319Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:14:38.624345Z","iopub.execute_input":"2025-08-07T15:14:38.624654Z","iopub.status.idle":"2025-08-07T15:14:38.63816Z","shell.execute_reply.started":"2025-08-07T15:14:38.624631Z","shell.execute_reply":"2025-08-07T15:14:38.633293Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**🧠 Feature Explanations**\n\n* **SeriesInstanceUID:**\tUnique ID for a DICOM series (a set of CT images). This links each row to a  folder containing .dcm slices of a head scan.\n* **PatientAge:**\t        Age of the patient (usually in years, sometimes with a suffix like 045Y).\n* **PatientSex:**\t        Gender of the patient (M or F).\n* **Modality:**           Imaging type. For this dataset, it's likely always CT (Computed Tomography), specifically CTA (CT Angiography).\n\n**🧠 Vascular Anatomy Features (Columns 5–17)**\n\nThese columns represent locations in the brain's blood vessels where an aneurysm may or may not be present. Each is a binary column (0 or 1) indicating presence of an aneurysm at that location:\n\n**Left Infraclinoid Internal Carotid Artery:**\tAneurysm present in the left side of the infraclinoid segment of the internal carotid artery (ICA).\n\n**Right Infraclinoid Internal Carotid Artery:**\tSame as above, but on the right side.\n\n**Left Supraclinoid Internal Carotid Artery\tAbove the clinoid process in the left ICA.\n\n**Right Supraclinoid Internal Carotid Artery:**\tSame, on the right ICA.\n\n**Left Middle Cerebral Artery (MCA):**\tAneurysm in left MCA, which supplies large portions of the brain.\n\n**Right Middle Cerebral Artery:**\tSame on the right side.\n\n**Anterior Communicating Artery (AComA):**\tThis is a small artery connecting both anterior cerebral arteries; aneurysms here are common.\n\n**Left Anterior Cerebral Artery (ACA):**\tAneurysm in left ACA, which supplies frontal brain regions.\n\n**Right Anterior Cerebral Artery:**\tSame, right side.\n\n**Left Posterior Communicating Artery (PComA):**\tConnecting vessel between posterior cerebral and internal carotid.\n\n**Right Posterior Communicating Artery:**\tSame on right.\n\n**Basilar Tip:**\tThe end of the basilar artery (posterior circulation). Common location for aneurysms.\n\n**Other Posterior Circulation:**\tAny other aneurysm in the posterior circulation not listed above (e.g., vertebral artery, posterior cerebral artery).\n\n**🎯 Aneurysm Present:**\n\nBinary target (1 or 0).\n\n* If 1, at least one of the vessels listed above has an aneurysm.\n\n* If 0, none of the vessel columns have 1.","metadata":{"execution":{"iopub.status.busy":"2025-08-07T15:26:15.711077Z","iopub.execute_input":"2025-08-07T15:26:15.711399Z","iopub.status.idle":"2025-08-07T15:26:15.729966Z","shell.execute_reply.started":"2025-08-07T15:26:15.711371Z","shell.execute_reply":"2025-08-07T15:26:15.72426Z"}}},{"cell_type":"code","source":"sns.histplot(df[\"Modality\"], color='purple', multiple='dodge')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:42:26.871056Z","iopub.execute_input":"2025-08-07T15:42:26.871371Z","iopub.status.idle":"2025-08-07T15:42:27.023135Z","shell.execute_reply.started":"2025-08-07T15:42:26.871343Z","shell.execute_reply":"2025-08-07T15:42:27.018314Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.histplot(data= df, x=\"PatientAge\", \n             hue=\"PatientSex\", \n             kde=True, \n             bins=30, \n             multiple='stack', \n             palette='Set2', \n             edgecolor='black')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-07T15:39:36.227232Z","iopub.execute_input":"2025-08-07T15:39:36.227555Z","iopub.status.idle":"2025-08-07T15:39:36.600972Z","shell.execute_reply.started":"2025-08-07T15:39:36.22753Z","shell.execute_reply":"2025-08-07T15:39:36.596819Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Age Distribution:**\n\n* The most common age range appears to be between 50–70 years.\n\n* This is where both male and female densities peak.\n\n**Sex-Based Difference:**\n\n* There seem to be more female patients than male in most age brackets (especially 50–70).\n\n* The KDE curve for females is higher, indicating a larger sample size.","metadata":{"execution":{"iopub.status.busy":"2025-08-07T15:45:21.46372Z","iopub.execute_input":"2025-08-07T15:45:21.464112Z","iopub.status.idle":"2025-08-07T15:45:21.476592Z","shell.execute_reply.started":"2025-08-07T15:45:21.46408Z","shell.execute_reply":"2025-08-07T15:45:21.472025Z"}}},{"cell_type":"code","source":"fig = px.pie(\n    df[df[\"Aneurysm Present\"]==1],\n    names=\"PatientSex\",\n    title=\"Patient Sex Distribution\",\n    color=\"PatientSex\",  # This links to the color map\n    color_discrete_map={\n        \"Male\": \"lightblue\",\n        \"Female\": \"pink\"\n    }\n)\n\nfig.show(renderer='iframe_connected')","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}