{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":13451,"databundleVersionId":1188070,"sourceType":"competition"}],"dockerImageVersionId":30919,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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        print(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-03-09T06:33:59.667739Z","iopub.execute_input":"2025-03-09T06:33:59.668011Z"},"collapsed":true,"jupyter":{"outputs_hidden":true}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip list | grep -E 'tensorflow|syft|torch'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:32:36.247824Z","iopub.execute_input":"2025-03-09T07:32:36.248184Z","iopub.status.idle":"2025-03-09T07:32:37.48057Z","shell.execute_reply.started":"2025-03-09T07:32:36.248152Z","shell.execute_reply":"2025-03-09T07:32:37.479755Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\n# Check all datasets available in Kaggle input directory\nprint(\"Available datasets in Kaggle environment:\")\nprint(os.listdir(\"/kaggle/input\"))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:32:41.047683Z","iopub.execute_input":"2025-03-09T07:32:41.047986Z","iopub.status.idle":"2025-03-09T07:32:41.053566Z","shell.execute_reply.started":"2025-03-09T07:32:41.04796Z","shell.execute_reply":"2025-03-09T07:32:41.052616Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"base_dir = \"/kaggle/input/rsna-intracranial-hemorrhage-detection\"\nprint(\"Dataset structure:\")\nfor item in os.listdir(base_dir):\n    print(item)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:32:43.902269Z","iopub.execute_input":"2025-03-09T07:32:43.902561Z","iopub.status.idle":"2025-03-09T07:32:43.90848Z","shell.execute_reply.started":"2025-03-09T07:32:43.902536Z","shell.execute_reply":"2025-03-09T07:32:43.907833Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\n# Define the dataset path\nbase_dir = \"/kaggle/input/rsna-intracranial-hemorrhage-detection\"\n\n# List dataset files and folders\nprint(\"Dataset structure:\")\nfor item in os.listdir(base_dir):\n    item_path = os.path.join(base_dir, item)\n    if os.path.isdir(item_path):\n        print(f\"[DIR] {item}\")\n    else:\n        print(f\"[FILE] {item}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:32:49.081154Z","iopub.execute_input":"2025-03-09T07:32:49.081435Z","iopub.status.idle":"2025-03-09T07:32:49.087389Z","shell.execute_reply.started":"2025-03-09T07:32:49.081413Z","shell.execute_reply":"2025-03-09T07:32:49.086646Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\n\n# Define dataset path\nbase_dir = \"/kaggle/input/rsna-intracranial-hemorrhage-detection\"\n\n# List files and folders\nprint(\"Dataset structure:\")\nfor item in os.listdir(base_dir):\n    item_path = os.path.join(base_dir, item)\n    if os.path.isdir(item_path):\n        print(f\"[DIR] {item}\")\n        print(os.listdir(item_path)[:5])  # Show first 5 files in the directory\n    else:\n        print(f\"[FILE] {item}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:34:20.29354Z","iopub.execute_input":"2025-03-09T07:34:20.293838Z","iopub.status.idle":"2025-03-09T07:34:20.300072Z","shell.execute_reply.started":"2025-03-09T07:34:20.293812Z","shell.execute_reply":"2025-03-09T07:34:20.299426Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\n\n# Define path to labels CSV\ntrain_csv_path = \"/kaggle/input/rsna-intracranial-hemorrhage-detection/rsna-intracranial-hemorrhage-detection/stage_2_train.csv\"\n\n# Load the CSV file\ndf = pd.read_csv(train_csv_path)\n\n# Display basic info and first few rows\nprint(\"Dataset Info:\")\nprint(df.info())\n\nprint(\"\\nFirst few rows:\")\nprint(df.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:35:26.683966Z","iopub.execute_input":"2025-03-09T07:35:26.68429Z","iopub.status.idle":"2025-03-09T07:35:30.473073Z","shell.execute_reply.started":"2025-03-09T07:35:26.68426Z","shell.execute_reply":"2025-03-09T07:35:30.472213Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Split 'ID' column into 'image_id' and 'hemorrhage_type'\ndf[['image_id', 'hemorrhage_type']] = df['ID'].str.rsplit('_', n=1, expand=True)\n\n# Drop the original 'ID' column\ndf.drop(columns=['ID'], inplace=True)\n\n# Display updated dataset\nprint(\"Updated Dataset Structure:\")\nprint(df.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-09T07:36:31.249481Z","iopub.execute_input":"2025-03-09T07:36:31.249776Z","iopub.status.idle":"2025-03-09T07:36:39.773207Z","shell.execute_reply.started":"2025-03-09T07:36:31.249756Z","shell.execute_reply":"2025-03-09T07:36:39.772312Z"}},"outputs":[],"execution_count":null}]}