{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":71549,"databundleVersionId":8561470,"sourceType":"competition"}],"dockerImageVersionId":30746,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport cv2\nimport pydicom\nimport numpy as np\nimport os\nimport glob\nfrom tqdm import tqdm\nimport warnings","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-07-24T04:06:32.852019Z","iopub.execute_input":"2024-07-24T04:06:32.852454Z","iopub.status.idle":"2024-07-24T04:06:32.858806Z","shell.execute_reply.started":"2024-07-24T04:06:32.852419Z","shell.execute_reply":"2024-07-24T04:06:32.857468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Load the datasets\ntrain = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train.csv')\nlabel_coordinates_df = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/train_label_coordinates.csv')","metadata":{"execution":{"iopub.status.busy":"2024-07-24T04:21:50.628952Z","iopub.execute_input":"2024-07-24T04:21:50.629783Z","iopub.status.idle":"2024-07-24T04:21:50.716128Z","shell.execute_reply.started":"2024-07-24T04:21:50.629749Z","shell.execute_reply":"2024-07-24T04:21:50.714883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2024-07-24T04:06:32.897690Z","iopub.execute_input":"2024-07-24T04:06:32.898255Z","iopub.status.idle":"2024-07-24T04:06:32.915233Z","shell.execute_reply.started":"2024-07-24T04:06:32.898214Z","shell.execute_reply":"2024-07-24T04:06:32.913924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2024-07-24T04:06:32.916751Z","iopub.execute_input":"2024-07-24T04:06:32.917216Z","iopub.status.idle":"2024-07-24T04:06:32.946869Z","shell.execute_reply.started":"2024-07-24T04:06:32.917177Z","shell.execute_reply":"2024-07-24T04:06:32.945483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.shape)\nprint(label_coordinates_df.shape)","metadata":{"execution":{"iopub.status.busy":"2024-07-24T04:22:52.069395Z","iopub.execute_input":"2024-07-24T04:22:52.069849Z","iopub.status.idle":"2024-07-24T04:22:52.075988Z","shell.execute_reply.started":"2024-07-24T04:22:52.069817Z","shell.execute_reply":"2024-07-24T04:22:52.074832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.duplicated().sum())\nprint(label_coordinates_df.duplicated().sum())","metadata":{"execution":{"iopub.status.busy":"2024-07-24T04:23:37.671253Z","iopub.execute_input":"2024-07-24T04:23:37.671671Z","iopub.status.idle":"2024-07-24T04:23:37.705744Z","shell.execute_reply.started":"2024-07-24T04:23:37.671641Z","shell.execute_reply":"2024-07-24T04:23:37.704570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.isnull().sum())\nprint(\"\")\nprint(label_coordinates_df.isnull().sum())","metadata":{"execution":{"iopub.status.busy":"2024-07-24T04:24:21.486238Z","iopub.execute_input":"2024-07-24T04:24:21.486633Z","iopub.status.idle":"2024-07-24T04:24:21.503991Z","shell.execute_reply.started":"2024-07-24T04:24:21.486605Z","shell.execute_reply":"2024-07-24T04:24:21.502630Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"figure, axis = plt.subplots(1,3, figsize=(20,5)) \nfor idx, d in enumerate(['foraminal', 'subarticular', 'canal']):\n    diagnosis = list(filter(lambda x: x.find(d) > -1, train.columns))\n    dff = train[diagnosis]\n    with warnings.catch_warnings():\n        warnings.simplefilter(action='ignore', category=FutureWarning)\n        value_counts = dff.apply(pd.value_counts).fillna(0).T\n    value_counts.plot(kind='bar', stacked=True, ax=axis[idx])\n    axis[idx].set_title(f'{d} distribution')","metadata":{"execution":{"iopub.status.busy":"2024-07-24T04:37:22.461679Z","iopub.execute_input":"2024-07-24T04:37:22.462116Z","iopub.status.idle":"2024-07-24T04:37:23.647141Z","shell.execute_reply.started":"2024-07-24T04:37:22.462086Z","shell.execute_reply":"2024-07-24T04:37:23.646002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}