{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":71549,"databundleVersionId":8561470,"sourceType":"competition"}],"dockerImageVersionId":30762,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2024-09-01T06:26:21.545947Z","iopub.execute_input":"2024-09-01T06:26:21.546556Z","iopub.status.idle":"2024-09-01T06:26:23.400275Z","shell.execute_reply.started":"2024-09-01T06:26:21.546517Z","shell.execute_reply":"2024-09-01T06:26:23.39938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 1 Exploratory data analysis","metadata":{}},{"cell_type":"markdown","source":"## 1.1 Importing data","metadata":{}},{"cell_type":"code","source":"# load dataset\ndf = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train.csv')\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2024-09-01T06:26:23.402042Z","iopub.execute_input":"2024-09-01T06:26:23.40382Z","iopub.status.idle":"2024-09-01T06:26:23.465789Z","shell.execute_reply.started":"2024-09-01T06:26:23.403762Z","shell.execute_reply":"2024-09-01T06:26:23.464585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 1.2 Data overview","metadata":{}},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2024-09-01T06:26:23.467424Z","iopub.execute_input":"2024-09-01T06:26:23.467834Z","iopub.status.idle":"2024-09-01T06:26:23.475112Z","shell.execute_reply.started":"2024-09-01T06:26:23.467788Z","shell.execute_reply":"2024-09-01T06:26:23.47395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.describe","metadata":{"execution":{"iopub.status.busy":"2024-09-01T06:26:23.477101Z","iopub.execute_input":"2024-09-01T06:26:23.477449Z","iopub.status.idle":"2024-09-01T06:26:23.513606Z","shell.execute_reply.started":"2024-09-01T06:26:23.477401Z","shell.execute_reply":"2024-09-01T06:26:23.51258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-09-01T06:26:23.514842Z","iopub.execute_input":"2024-09-01T06:26:23.5152Z","iopub.status.idle":"2024-09-01T06:26:23.544939Z","shell.execute_reply.started":"2024-09-01T06:26:23.515157Z","shell.execute_reply":"2024-09-01T06:26:23.543767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nfrom PIL import Image\nfrom tqdm import tqdm","metadata":{"execution":{"iopub.status.busy":"2024-09-01T06:59:21.947888Z","iopub.execute_input":"2024-09-01T06:59:21.948759Z","iopub.status.idle":"2024-09-01T06:59:22.143654Z","shell.execute_reply.started":"2024-09-01T06:59:21.948716Z","shell.execute_reply":"2024-09-01T06:59:22.142646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def load_and_preprocess_image(\"/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_images\"):\n    # Load the image using OpenCV\n    img = cv2.imread(image_path)\n    \n    # Convert the image to grayscale if it's not already\n    if len(img.shape) == 3:\n        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n    \n    # Normalize the pixel values between 0 and 1\n    img = img.astype(np.float32) / 255.0\n    \n    return img","metadata":{"execution":{"iopub.status.busy":"2024-09-01T07:03:20.136195Z","iopub.execute_input":"2024-09-01T07:03:20.136748Z","iopub.status.idle":"2024-09-01T07:03:20.144488Z","shell.execute_reply.started":"2024-09-01T07:03:20.136553Z","shell.execute_reply":"2024-09-01T07:03:20.143172Z"},"trusted":true},"execution_count":null,"outputs":[]}]}