{"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","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.515142Z","iopub.execute_input":"2022-08-12T14:50:17.515848Z","iopub.status.idle":"2022-08-12T14:50:17.520092Z","shell.execute_reply.started":"2022-08-12T14:50:17.51581Z","shell.execute_reply":"2022-08-12T14:50:17.519167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as s","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.522404Z","iopub.execute_input":"2022-08-12T14:50:17.523061Z","iopub.status.idle":"2022-08-12T14:50:17.533109Z","shell.execute_reply.started":"2022-08-12T14:50:17.523025Z","shell.execute_reply":"2022-08-12T14:50:17.532128Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.534776Z","iopub.execute_input":"2022-08-12T14:50:17.53555Z","iopub.status.idle":"2022-08-12T14:50:17.542181Z","shell.execute_reply.started":"2022-08-12T14:50:17.535506Z","shell.execute_reply":"2022-08-12T14:50:17.541041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.543734Z","iopub.execute_input":"2022-08-12T14:50:17.544109Z","iopub.status.idle":"2022-08-12T14:50:17.553031Z","shell.execute_reply.started":"2022-08-12T14:50:17.544078Z","shell.execute_reply":"2022-08-12T14:50:17.552015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.556283Z","iopub.execute_input":"2022-08-12T14:50:17.556681Z","iopub.status.idle":"2022-08-12T14:50:17.56447Z","shell.execute_reply.started":"2022-08-12T14:50:17.556647Z","shell.execute_reply":"2022-08-12T14:50:17.563657Z"},"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-08-12T14:50:17.565645Z","iopub.execute_input":"2022-08-12T14:50:17.566809Z","iopub.status.idle":"2022-08-12T14:50:17.592552Z","shell.execute_reply.started":"2022-08-12T14:50:17.566764Z","shell.execute_reply":"2022-08-12T14:50:17.591384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df=pd.read_csv(\"../input/rsna-2022-cervical-spine-fracture-detection/train.csv\")\ntrain_df","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.595014Z","iopub.execute_input":"2022-08-12T14:50:17.595412Z","iopub.status.idle":"2022-08-12T14:50:17.616915Z","shell.execute_reply.started":"2022-08-12T14:50:17.595379Z","shell.execute_reply":"2022-08-12T14:50:17.615801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.618506Z","iopub.execute_input":"2022-08-12T14:50:17.6192Z","iopub.status.idle":"2022-08-12T14:50:17.626447Z","shell.execute_reply.started":"2022-08-12T14:50:17.619158Z","shell.execute_reply":"2022-08-12T14:50:17.62547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.627807Z","iopub.execute_input":"2022-08-12T14:50:17.628905Z","iopub.status.idle":"2022-08-12T14:50:17.637893Z","shell.execute_reply.started":"2022-08-12T14:50:17.628869Z","shell.execute_reply":"2022-08-12T14:50:17.636738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head(15)","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.64044Z","iopub.execute_input":"2022-08-12T14:50:17.641466Z","iopub.status.idle":"2022-08-12T14:50:17.658922Z","shell.execute_reply.started":"2022-08-12T14:50:17.641312Z","shell.execute_reply":"2022-08-12T14:50:17.657984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.660196Z","iopub.execute_input":"2022-08-12T14:50:17.660985Z","iopub.status.idle":"2022-08-12T14:50:17.671087Z","shell.execute_reply.started":"2022-08-12T14:50:17.660941Z","shell.execute_reply":"2022-08-12T14:50:17.669723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x=train_df[['C1','C2','C3','C4','C5','C6','C7']].values\nx","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.672774Z","iopub.execute_input":"2022-08-12T14:50:17.673548Z","iopub.status.idle":"2022-08-12T14:50:17.682619Z","shell.execute_reply.started":"2022-08-12T14:50:17.673506Z","shell.execute_reply":"2022-08-12T14:50:17.681482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y=train_df[['patient_overall']].values\ny","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.686019Z","iopub.execute_input":"2022-08-12T14:50:17.686653Z","iopub.status.idle":"2022-08-12T14:50:17.696789Z","shell.execute_reply.started":"2022-08-12T14:50:17.686612Z","shell.execute_reply":"2022-08-12T14:50:17.695622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = LogisticRegression()\nmodel.fit(x, y)\ny_pred = model.predict(x)\n\nprint(\"accuracy:\", accuracy_score(y, y_pred))\nprint(\"precision:\", precision_score(y, y_pred))\nprint(\"recall:\", recall_score(y, y_pred))\nprint(\"f1 score:\", f1_score(y, y_pred))","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.709747Z","iopub.execute_input":"2022-08-12T14:50:17.710685Z","iopub.status.idle":"2022-08-12T14:50:17.751723Z","shell.execute_reply.started":"2022-08-12T14:50:17.710651Z","shell.execute_reply":"2022-08-12T14:50:17.750218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train, x_test, y_train, y_test = train_test_split(x, y)\n\nprint(\"whole dataset:\", x.shape, y.shape)\nprint(\"training set:\", x_train.shape, y_train.shape)\nprint(\"test set:\", x_test.shape, y_test.shape)","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.755278Z","iopub.execute_input":"2022-08-12T14:50:17.756678Z","iopub.status.idle":"2022-08-12T14:50:17.771699Z","shell.execute_reply.started":"2022-08-12T14:50:17.756614Z","shell.execute_reply":"2022-08-12T14:50:17.770026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.77426Z","iopub.execute_input":"2022-08-12T14:50:17.775476Z","iopub.status.idle":"2022-08-12T14:50:17.782424Z","shell.execute_reply.started":"2022-08-12T14:50:17.775406Z","shell.execute_reply":"2022-08-12T14:50:17.780873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(confusion_matrix(y, y_pred))","metadata":{"execution":{"iopub.status.busy":"2022-08-12T14:50:17.784825Z","iopub.execute_input":"2022-08-12T14:50:17.785841Z","iopub.status.idle":"2022-08-12T14:50:17.798197Z","shell.execute_reply.started":"2022-08-12T14:50:17.785796Z","shell.execute_reply":"2022-08-12T14:50:17.796154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}