{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nfrom collections import OrderedDict","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-09-20T11:00:04.636243Z","iopub.execute_input":"2022-09-20T11:00:04.636911Z","iopub.status.idle":"2022-09-20T11:00:04.665014Z","shell.execute_reply.started":"2022-09-20T11:00:04.636816Z","shell.execute_reply":"2022-09-20T11:00:04.66398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv(\"../input/rsna-2022-cervical-spine-fracture-detection/train.csv\")\n\ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:00:08.540963Z","iopub.execute_input":"2022-09-20T11:00:08.541368Z","iopub.status.idle":"2022-09-20T11:00:08.581114Z","shell.execute_reply.started":"2022-09-20T11:00:08.541336Z","shell.execute_reply":"2022-09-20T11:00:08.580237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mean_train = OrderedDict()\nmean_train[\"Mean_values\"] = train_df.mean(axis=0,numeric_only=True,) \nmean_train","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:00:14.19864Z","iopub.execute_input":"2022-09-20T11:00:14.199039Z","iopub.status.idle":"2022-09-20T11:00:14.209822Z","shell.execute_reply.started":"2022-09-20T11:00:14.199008Z","shell.execute_reply":"2022-09-20T11:00:14.208477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"compition_weights = OrderedDict()\ncompition_weights[\"Not_present\"]=[1,1,1,1,1,1,1,7]\ncompition_weights[\"present\"]=[2,2,2,2,2,2,2,14]\n\ncompition_weights = pd.DataFrame(compition_weights)\ncompition_weights[\"mean_weights\"] = (compition_weights[\"Not_present\"] + compition_weights[\"present\"])/2\ncompition_weights","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:00:19.238441Z","iopub.execute_input":"2022-09-20T11:00:19.238847Z","iopub.status.idle":"2022-09-20T11:00:19.261035Z","shell.execute_reply.started":"2022-09-20T11:00:19.238814Z","shell.execute_reply":"2022-09-20T11:00:19.259705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"weights=train_df[\"patient_overall\"] + 1\n\nweights","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:00:30.604203Z","iopub.execute_input":"2022-09-20T11:00:30.605309Z","iopub.status.idle":"2022-09-20T11:00:30.614835Z","shell.execute_reply.started":"2022-09-20T11:00:30.605264Z","shell.execute_reply":"2022-09-20T11:00:30.613685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"weighted_means = dict(zip(train_df.columns[1:], np.average(train_df[train_df.columns[1:]], axis=0, weights=train_df[\"patient_overall\"] + np.average(compition_weights[\"mean_weights\"]))))\nweighted_means","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:00:40.697641Z","iopub.execute_input":"2022-09-20T11:00:40.698081Z","iopub.status.idle":"2022-09-20T11:00:40.71415Z","shell.execute_reply.started":"2022-09-20T11:00:40.698045Z","shell.execute_reply":"2022-09-20T11:00:40.712867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df= pd.read_csv(\"../input/rsna-2022-cervical-spine-fracture-detection/test.csv\")\ntest_df","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:01:02.323947Z","iopub.execute_input":"2022-09-20T11:01:02.324356Z","iopub.status.idle":"2022-09-20T11:01:02.341659Z","shell.execute_reply.started":"2022-09-20T11:01:02.324323Z","shell.execute_reply":"2022-09-20T11:01:02.340525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv(\"../input/submission-15lresnet50/submission1.5l.csv\")\n\nsub.head()","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:01:33.621151Z","iopub.execute_input":"2022-09-20T11:01:33.621595Z","iopub.status.idle":"2022-09-20T11:01:33.640566Z","shell.execute_reply.started":"2022-09-20T11:01:33.621565Z","shell.execute_reply":"2022-09-20T11:01:33.639489Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntest_df['fractured'] = sub['fractured']\n\ntest_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:04:45.589574Z","iopub.execute_input":"2022-09-20T11:04:45.590342Z","iopub.status.idle":"2022-09-20T11:04:45.602512Z","shell.execute_reply.started":"2022-09-20T11:04:45.590303Z","shell.execute_reply":"2022-09-20T11:04:45.601633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df[['row_id','fractured']].to_csv('submission.csv', index=False, float_format='%.2g')","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:04:54.226478Z","iopub.execute_input":"2022-09-20T11:04:54.226921Z","iopub.status.idle":"2022-09-20T11:04:54.241655Z","shell.execute_reply.started":"2022-09-20T11:04:54.226886Z","shell.execute_reply":"2022-09-20T11:04:54.240372Z"},"trusted":true},"execution_count":null,"outputs":[]}]}