{"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":30698,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## Table of Contents\n* [Data Preparation](#data_prep)\n* [EDA](#eda)\n* [Example](#example)\n* [Submission](#sub)","metadata":{}},{"cell_type":"code","source":"# packages\n\n# standard\nimport numpy as np\nimport pandas as pd\nimport os\nimport time\n\n# plots\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as patches\nimport plotly.express as px\nimport seaborn as sns\n\n# dicom\nimport pydicom as dicom","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-06-02T10:22:12.929098Z","iopub.execute_input":"2024-06-02T10:22:12.929497Z","iopub.status.idle":"2024-06-02T10:22:16.746027Z","shell.execute_reply.started":"2024-06-02T10:22:12.929463Z","shell.execute_reply":"2024-06-02T10:22:16.744735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# warning handling\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:25:44.111005Z","iopub.execute_input":"2024-06-02T10:25:44.111412Z","iopub.status.idle":"2024-06-02T10:25:44.116752Z","shell.execute_reply.started":"2024-06-02T10:25:44.111379Z","shell.execute_reply":"2024-06-02T10:25:44.115559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# show files\n!ls -l '../input/rsna-2024-lumbar-spine-degenerative-classification'","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:25:46.031737Z","iopub.execute_input":"2024-06-02T10:25:46.032529Z","iopub.status.idle":"2024-06-02T10:25:47.128547Z","shell.execute_reply.started":"2024-06-02T10:25:46.032492Z","shell.execute_reply":"2024-06-02T10:25:47.127097Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# configs\ndefault_color_1 = 'darkblue'","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:25:49.143197Z","iopub.execute_input":"2024-06-02T10:25:49.14363Z","iopub.status.idle":"2024-06-02T10:25:49.149195Z","shell.execute_reply.started":"2024-06-02T10:25:49.143594Z","shell.execute_reply":"2024-06-02T10:25:49.148036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# read data\ndf_train_main = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/train.csv')\ndf_train_label = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/train_label_coordinates.csv')\ndf_train_desc = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/train_series_descriptions.csv')\ndf_test_desc = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/test_series_descriptions.csv')\ndf_sub = pd.read_csv('../input/rsna-2024-lumbar-spine-degenerative-classification/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:25:51.190594Z","iopub.execute_input":"2024-06-02T10:25:51.191021Z","iopub.status.idle":"2024-06-02T10:25:51.374627Z","shell.execute_reply.started":"2024-06-02T10:25:51.190965Z","shell.execute_reply":"2024-06-02T10:25:51.3735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='data_prep'></a>\n# Data Preparation","metadata":{}},{"cell_type":"markdown","source":"### Main Table","metadata":{}},{"cell_type":"code","source":"# structure\ndf_train_main.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:25:54.560454Z","iopub.execute_input":"2024-06-02T10:25:54.560823Z","iopub.status.idle":"2024-06-02T10:25:54.607388Z","shell.execute_reply.started":"2024-06-02T10:25:54.560796Z","shell.execute_reply":"2024-06-02T10:25:54.606348Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview\ndf_train_main.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:25:57.829679Z","iopub.execute_input":"2024-06-02T10:25:57.830092Z","iopub.status.idle":"2024-06-02T10:25:57.863634Z","shell.execute_reply.started":"2024-06-02T10:25:57.830057Z","shell.execute_reply":"2024-06-02T10:25:57.862593Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Labels","metadata":{}},{"cell_type":"code","source":"# structure\ndf_train_label.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:01.448225Z","iopub.execute_input":"2024-06-02T10:26:01.448639Z","iopub.status.idle":"2024-06-02T10:26:01.471292Z","shell.execute_reply.started":"2024-06-02T10:26:01.448605Z","shell.execute_reply":"2024-06-02T10:26:01.47004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview\ndf_train_label.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:03.913379Z","iopub.execute_input":"2024-06-02T10:26:03.913762Z","iopub.status.idle":"2024-06-02T10:26:03.929475Z","shell.execute_reply.started":"2024-06-02T10:26:03.913736Z","shell.execute_reply":"2024-06-02T10:26:03.928283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# look at categories\nfor f in ['instance_number','condition','level']:\n    print(df_train_label[f].value_counts())\n    print()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:08.383417Z","iopub.execute_input":"2024-06-02T10:26:08.383808Z","iopub.status.idle":"2024-06-02T10:26:08.410716Z","shell.execute_reply.started":"2024-06-02T10:26:08.383777Z","shell.execute_reply":"2024-06-02T10:26:08.409411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# numerical plot for instance number\nplt.figure(figsize=(7,1))\ndf_train_label.instance_number.plot(kind='box', vert=False)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:15.329206Z","iopub.execute_input":"2024-06-02T10:26:15.32961Z","iopub.status.idle":"2024-06-02T10:26:15.581864Z","shell.execute_reply.started":"2024-06-02T10:26:15.329578Z","shell.execute_reply":"2024-06-02T10:26:15.580822Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# look at few rows with the very high instance numbers\ndf_train_label[df_train_label.instance_number>150]","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:18.376646Z","iopub.execute_input":"2024-06-02T10:26:18.377063Z","iopub.status.idle":"2024-06-02T10:26:18.393165Z","shell.execute_reply.started":"2024-06-02T10:26:18.37703Z","shell.execute_reply":"2024-06-02T10:26:18.392057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# condition vs level\npd.crosstab(df_train_label.condition, df_train_label.level)","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:20.448842Z","iopub.execute_input":"2024-06-02T10:26:20.449229Z","iopub.status.idle":"2024-06-02T10:26:20.489638Z","shell.execute_reply.started":"2024-06-02T10:26:20.449201Z","shell.execute_reply":"2024-06-02T10:26:20.488546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Descriptions","metadata":{}},{"cell_type":"code","source":"# structure\ndf_train_desc.info()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:24.952545Z","iopub.execute_input":"2024-06-02T10:26:24.952974Z","iopub.status.idle":"2024-06-02T10:26:24.964559Z","shell.execute_reply.started":"2024-06-02T10:26:24.952941Z","shell.execute_reply":"2024-06-02T10:26:24.963403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview\ndf_train_desc.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:27.537403Z","iopub.execute_input":"2024-06-02T10:26:27.537796Z","iopub.status.idle":"2024-06-02T10:26:27.548523Z","shell.execute_reply.started":"2024-06-02T10:26:27.537764Z","shell.execute_reply":"2024-06-02T10:26:27.547516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# look at categories\ncounts = df_train_desc.series_description.value_counts()\nprint(counts)\nplt.figure(figsize=(7,3))\ncounts.plot(kind='bar', color=default_color_1)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:30.041677Z","iopub.execute_input":"2024-06-02T10:26:30.042122Z","iopub.status.idle":"2024-06-02T10:26:30.266292Z","shell.execute_reply.started":"2024-06-02T10:26:30.042088Z","shell.execute_reply":"2024-06-02T10:26:30.265094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Combine Tables","metadata":{}},{"cell_type":"code","source":"# join first two tables\ndf_train_step_1 = pd.merge(left=df_train_label, right=df_train_main, how='left', on='study_id').reset_index(drop=True)\ndf_train_step_1.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:35.300541Z","iopub.execute_input":"2024-06-02T10:26:35.300911Z","iopub.status.idle":"2024-06-02T10:26:35.439699Z","shell.execute_reply.started":"2024-06-02T10:26:35.300884Z","shell.execute_reply":"2024-06-02T10:26:35.438646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_step_1[df_train_step_1.study_id==4003253]","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:39.733722Z","iopub.execute_input":"2024-06-02T10:26:39.734646Z","iopub.status.idle":"2024-06-02T10:26:39.773179Z","shell.execute_reply.started":"2024-06-02T10:26:39.73461Z","shell.execute_reply":"2024-06-02T10:26:39.7722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# join with third table\ndf_train = pd.merge(left=df_train_step_1, right=df_train_desc, how='left', on=['study_id', 'series_id']).reset_index(drop=True)\ndf_train.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:47.248462Z","iopub.execute_input":"2024-06-02T10:26:47.248861Z","iopub.status.idle":"2024-06-02T10:26:47.364802Z","shell.execute_reply.started":"2024-06-02T10:26:47.248829Z","shell.execute_reply":"2024-06-02T10:26:47.363738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# convert ids to categorical\ndf_train.study_id = df_train.study_id.astype('category')\ndf_train.series_id = df_train.series_id.astype('category')","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:26:49.577415Z","iopub.execute_input":"2024-06-02T10:26:49.577835Z","iopub.status.idle":"2024-06-02T10:26:49.58794Z","shell.execute_reply.started":"2024-06-02T10:26:49.577802Z","shell.execute_reply":"2024-06-02T10:26:49.586945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='eda'></a>\n# EDA","metadata":{}},{"cell_type":"code","source":"# plot coordinates\nsns.jointplot(data=df_train, x='x', y='y', \n              color=default_color_1, alpha=0.25)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:27:13.51294Z","iopub.execute_input":"2024-06-02T10:27:13.513378Z","iopub.status.idle":"2024-06-02T10:27:14.969122Z","shell.execute_reply.started":"2024-06-02T10:27:13.513347Z","shell.execute_reply":"2024-06-02T10:27:14.968031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot coordinates - colored by condition\nax = sns.jointplot(data=df_train, x='x', y='y', \n                   hue='condition', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:27:23.994509Z","iopub.execute_input":"2024-06-02T10:27:23.994883Z","iopub.status.idle":"2024-06-02T10:27:27.216097Z","shell.execute_reply.started":"2024-06-02T10:27:23.994854Z","shell.execute_reply":"2024-06-02T10:27:27.215098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot coordinates - colored by level\nsns.jointplot(data=df_train, x='x', y='y', \n              hue='level', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:27:30.992889Z","iopub.execute_input":"2024-06-02T10:27:30.993292Z","iopub.status.idle":"2024-06-02T10:27:34.312714Z","shell.execute_reply.started":"2024-06-02T10:27:30.993261Z","shell.execute_reply":"2024-06-02T10:27:34.311549Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot coordinates - colored by description\nsns.jointplot(data=df_train, x='x', y='y', \n              hue='series_description', alpha=0.25)\nplt.legend(bbox_to_anchor=(1.2,1), loc=2)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:27:38.170333Z","iopub.execute_input":"2024-06-02T10:27:38.170723Z","iopub.status.idle":"2024-06-02T10:27:41.370231Z","shell.execute_reply.started":"2024-06-02T10:27:38.170693Z","shell.execute_reply":"2024-06-02T10:27:41.369144Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Label distributions","metadata":{}},{"cell_type":"code","source":"labels = df_train_main.columns.drop('study_id').tolist()\nprint(labels)","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:27:50.013394Z","iopub.execute_input":"2024-06-02T10:27:50.013776Z","iopub.status.idle":"2024-06-02T10:27:50.020302Z","shell.execute_reply.started":"2024-06-02T10:27:50.013747Z","shell.execute_reply":"2024-06-02T10:27:50.019035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot label distributions\nfor l in labels:\n    plt.figure(figsize=(6,2))\n    counts = df_train_main[l].value_counts(normalize=True)\n    print(counts)\n    counts.plot(kind='bar', color=default_color_1)\n    plt.grid()\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:27:53.754919Z","iopub.execute_input":"2024-06-02T10:27:53.755319Z","iopub.status.idle":"2024-06-02T10:27:59.03174Z","shell.execute_reply.started":"2024-06-02T10:27:53.755291Z","shell.execute_reply":"2024-06-02T10:27:59.030591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# create frequency table for the labels\nfreqs = pd.DataFrame(labels, columns=['label'])\nfreqs['p1'] = 1.0\nfreqs['p2'] = 0.0\nfreqs['p3'] = 0.0\n\nfor l in labels:\n    rel_counts = df_train_main[l].value_counts(normalize=True)\n    freqs.loc[freqs.label==l, 'p1'] = rel_counts['Normal/Mild']\n    freqs.loc[freqs.label==l, 'p2'] = rel_counts['Moderate']\n    freqs.loc[freqs.label==l, 'p3'] = rel_counts['Severe']","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:28:09.179833Z","iopub.execute_input":"2024-06-02T10:28:09.180996Z","iopub.status.idle":"2024-06-02T10:28:09.25285Z","shell.execute_reply.started":"2024-06-02T10:28:09.180945Z","shell.execute_reply":"2024-06-02T10:28:09.251689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# show frequency table\nfreqs","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:28:13.419172Z","iopub.execute_input":"2024-06-02T10:28:13.419548Z","iopub.status.idle":"2024-06-02T10:28:13.435887Z","shell.execute_reply.started":"2024-06-02T10:28:13.419521Z","shell.execute_reply":"2024-06-02T10:28:13.434765Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# make combined table available for download\ndf_train.to_csv('df_train.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:28:18.027855Z","iopub.execute_input":"2024-06-02T10:28:18.028403Z","iopub.status.idle":"2024-06-02T10:28:19.488374Z","shell.execute_reply.started":"2024-06-02T10:28:18.028334Z","shell.execute_reply":"2024-06-02T10:28:19.487411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='example'></a>\n# Example","metadata":{}},{"cell_type":"code","source":"tmp_ds = dicom.dcmread('../input/rsna-2024-lumbar-spine-degenerative-classification/train_images/4646740/3666319702/12.dcm')\nprint(tmp_ds)\nprint(tmp_ds.dir())\nprint(tmp_ds.ImagePositionPatient)\n","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:29:16.580669Z","iopub.execute_input":"2024-06-02T10:29:16.581098Z","iopub.status.idle":"2024-06-02T10:29:16.602191Z","shell.execute_reply.started":"2024-06-02T10:29:16.581066Z","shell.execute_reply":"2024-06-02T10:29:16.600891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_labels(df, file_path):\n    study_id = int(file_path.split('/')[-3])\n    series_id = int(file_path.split('/')[-2])\n    instance_number = int(file_path.split('/')[-1][:-4])\n    return df[(df.study_id==study_id) & (df.series_id==series_id) & (df.instance_number==instance_number)]\n\ndef show_image(ax, file_path, df, only_with_labels=False):\n    ds = dicom.dcmread(file_path)\n    img = ds.pixel_array\n    \n    if not only_with_labels or len(df) > 0:\n        ax.axis('off')\n        title = file_path[file_path.find('train_images')+len('train_images')+1:]\n        ax.set_title(title)\n        ax.imshow(img)\n        for index, row in df.iterrows():\n            x, y = row['x'], row['y']\n            a = 10\n            rect = patches.Rectangle((x - a, y - a), 2*a, 2*a, linewidth=2, edgecolor='white', facecolor='none')\n            ax.add_patch(rect)\n            ax.text(x + a + 2, y+np.random.randint(-10, 10), row['level']+' '+row['condition'], fontsize=8, color='white')\n        \nimport re\n\ndef show_samples(study_id):\n    df_ex = df_train[df_train.study_id==study_id] \n    # create file path and show files\n    my_path = '../input/rsna-2024-lumbar-spine-degenerative-classification/train_images/' + str(study_id) + '/'\n    file_paths = []\n    for dirname, _, filenames in os.walk(my_path):\n        file_paths_per_dir = []\n        if len(filenames) > 0:\n            for filename in filenames:\n                file_paths_per_dir.append(os.path.join(dirname, filename))\n            file_paths_per_dir.sort(key=lambda s: int(re.findall(r'\\d+', s)[-1]))\n            file_paths.extend(file_paths_per_dir)\n            \n            num_of_images = len(file_paths_per_dir)\n            fig, axis = plt.subplots((num_of_images+2)//3, 3, tight_layout=True, figsize=(15, (num_of_images+2)//3*5))\n            for i, file_path in enumerate(file_paths_per_dir):\n                show_image(axis[i//3, i%3], file_path, get_labels(df_ex, file_path))\n            plt.show()\n    \n#show_samples(4003253)\nshow_samples(4646740)","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:37:13.540339Z","iopub.execute_input":"2024-06-02T10:37:13.541099Z","iopub.status.idle":"2024-06-02T10:37:36.927746Z","shell.execute_reply.started":"2024-06-02T10:37:13.541068Z","shell.execute_reply":"2024-06-02T10:37:36.925777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='sub'></a>\n# Submission","metadata":{}},{"cell_type":"code","source":"# preview test data\ndf_test_desc.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:30:31.263466Z","iopub.execute_input":"2024-06-02T10:30:31.263867Z","iopub.status.idle":"2024-06-02T10:30:31.274632Z","shell.execute_reply.started":"2024-06-02T10:30:31.263836Z","shell.execute_reply":"2024-06-02T10:30:31.273422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview sample submission\ndf_sub.head()","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:30:35.61492Z","iopub.execute_input":"2024-06-02T10:30:35.61534Z","iopub.status.idle":"2024-06-02T10:30:35.628231Z","shell.execute_reply.started":"2024-06-02T10:30:35.615304Z","shell.execute_reply":"2024-06-02T10:30:35.627138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# setup baseline model just using observed frequencies\nn = df_sub.shape[0]\nfor i in range(0,n):\n    # extract label from id\n    current_label = df_sub.loc[i, 'row_id'].split('_',1)[1]\n    # look up frequencies in frequency table\n    p1 = freqs.loc[freqs.label==current_label, 'p1'].min()\n    p2 = freqs.loc[freqs.label==current_label, 'p2'].min()\n    p3 = freqs.loc[freqs.label==current_label, 'p3'].min()\n    # transfer results to submission table\n    df_sub.loc[i, 'normal_mild'] = p1\n    df_sub.loc[i, 'moderate'] = p2\n    df_sub.loc[i, 'severe'] = p3","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:31:14.207338Z","iopub.execute_input":"2024-06-02T10:31:14.207768Z","iopub.status.idle":"2024-06-02T10:31:14.276035Z","shell.execute_reply.started":"2024-06-02T10:31:14.207739Z","shell.execute_reply":"2024-06-02T10:31:14.274842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview\ndf_sub","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:31:16.286704Z","iopub.execute_input":"2024-06-02T10:31:16.287113Z","iopub.status.idle":"2024-06-02T10:31:16.304211Z","shell.execute_reply.started":"2024-06-02T10:31:16.287082Z","shell.execute_reply":"2024-06-02T10:31:16.303124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# save submission file\n#df_sub.to_csv('submission_freq.csv', index=False)\ndf_sub.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:31:20.521233Z","iopub.execute_input":"2024-06-02T10:31:20.521668Z","iopub.status.idle":"2024-06-02T10:31:20.528584Z","shell.execute_reply.started":"2024-06-02T10:31:20.521635Z","shell.execute_reply":"2024-06-02T10:31:20.527525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# simple version, just fixed values\nn = df_sub.shape[0]\nfor i in range(0,n):\n    df_sub.loc[i, 'normal_mild'] = 0.34\n    df_sub.loc[i, 'moderate'] = 0.33\n    df_sub.loc[i, 'severe'] = 0.33","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:31:23.303256Z","iopub.execute_input":"2024-06-02T10:31:23.303662Z","iopub.status.idle":"2024-06-02T10:31:23.334243Z","shell.execute_reply.started":"2024-06-02T10:31:23.303631Z","shell.execute_reply":"2024-06-02T10:31:23.333044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# save submission file\ndf_sub.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:31:26.471304Z","iopub.execute_input":"2024-06-02T10:31:26.471699Z","iopub.status.idle":"2024-06-02T10:31:26.47811Z","shell.execute_reply.started":"2024-06-02T10:31:26.471668Z","shell.execute_reply":"2024-06-02T10:31:26.477086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_sub","metadata":{"execution":{"iopub.status.busy":"2024-06-02T10:31:28.70309Z","iopub.execute_input":"2024-06-02T10:31:28.704417Z","iopub.status.idle":"2024-06-02T10:31:28.724743Z","shell.execute_reply.started":"2024-06-02T10:31:28.704378Z","shell.execute_reply":"2024-06-02T10:31:28.723529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}