{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-20T02:51:23.280155Z","iopub.execute_input":"2022-07-20T02:51:23.280554Z","iopub.status.idle":"2022-07-20T02:51:23.293946Z","shell.execute_reply.started":"2022-07-20T02:51:23.280519Z","shell.execute_reply":"2022-07-20T02:51:23.292618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport plotly.express as px\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objects as go\nfrom matplotlib import rcParams\n\nfrom sklearn import model_selection\nfrom xgboost import XGBClassifier\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.ensemble import GradientBoostingClassifier\nfrom sklearn.metrics import accuracy_score, precision_score, recall_score, roc_auc_score\nfrom sklearn.metrics import f1_score, confusion_matrix, precision_recall_curve, roc_curve\nfrom sklearn.metrics import ConfusionMatrixDisplay\nfrom sklearn.preprocessing import StandardScaler\n\nimport warnings\nwarnings.filterwarnings(action='ignore')\n\nimport plotly.express as px\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objects as go","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:23.662646Z","iopub.execute_input":"2022-07-20T02:51:23.663066Z","iopub.status.idle":"2022-07-20T02:51:23.677753Z","shell.execute_reply.started":"2022-07-20T02:51:23.663029Z","shell.execute_reply":"2022-07-20T02:51:23.676660Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv(\"../input/spaceship-titanic/train.csv\")\ndf_test = pd.read_csv(\"../input/spaceship-titanic/test.csv\")\n","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:24.034218Z","iopub.execute_input":"2022-07-20T02:51:24.034609Z","iopub.status.idle":"2022-07-20T02:51:24.083046Z","shell.execute_reply.started":"2022-07-20T02:51:24.034575Z","shell.execute_reply":"2022-07-20T02:51:24.082188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## <span style=\"color:#e76f51;\"> Column Descriptions  : </span>\n\n\n- `PassengerId` - A unique Id for each passenger. Each Id takes the form gggg_pp where gggg indicates a group the passenger is travelling with and pp is their number within the group. People in a group are often family members, but not always.\n- `HomePlanet` - The planet the passenger departed from, typically their planet of permanent residence.\n- `CryoSleep` - Indicates whether the passenger elected to be put into suspended animation for the duration of the voyage. Passengers in cryosleep are confined to their cabins.\n- `Cabin` - The cabin number where the passenger is staying. Takes the form deck/num/side, where side can be either P for Port or S for Starboard.\n- `Destination` - The planet the passenger will be debarking to.\n- `Age` - The age of the passenger.\n- `VIP` - Whether the passenger has paid for special VIP service during the voyage.\n- `RoomService`, FoodCourt, ShoppingMall, Spa, VRDeck - Amount the passenger has billed at each of the Spaceship Titanic's many luxury amenities.\n- `Name` - The first and last names of the passenger.\n- `Transported` - Whether the passenger was transported to another dimension. This is the target, the column you are trying to predict.\n\n","metadata":{}},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:24.429195Z","iopub.execute_input":"2022-07-20T02:51:24.431896Z","iopub.status.idle":"2022-07-20T02:51:24.463192Z","shell.execute_reply.started":"2022-07-20T02:51:24.431848Z","shell.execute_reply":"2022-07-20T02:51:24.462112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:24.811569Z","iopub.execute_input":"2022-07-20T02:51:24.812307Z","iopub.status.idle":"2022-07-20T02:51:24.841404Z","shell.execute_reply.started":"2022-07-20T02:51:24.812269Z","shell.execute_reply":"2022-07-20T02:51:24.840457Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:25.198016Z","iopub.execute_input":"2022-07-20T02:51:25.199262Z","iopub.status.idle":"2022-07-20T02:51:25.219900Z","shell.execute_reply.started":"2022-07-20T02:51:25.199214Z","shell.execute_reply":"2022-07-20T02:51:25.218708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.describe().transpose()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:25.580295Z","iopub.execute_input":"2022-07-20T02:51:25.581059Z","iopub.status.idle":"2022-07-20T02:51:25.617747Z","shell.execute_reply.started":"2022-07-20T02:51:25.581005Z","shell.execute_reply":"2022-07-20T02:51:25.616493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.corr()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:25.962664Z","iopub.execute_input":"2022-07-20T02:51:25.963567Z","iopub.status.idle":"2022-07-20T02:51:25.981185Z","shell.execute_reply.started":"2022-07-20T02:51:25.963524Z","shell.execute_reply":"2022-07-20T02:51:25.980046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,7))\ndf_train.corr()\nsns.heatmap(df_train.corr(),annot=True)\nplt.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:26.312608Z","iopub.execute_input":"2022-07-20T02:51:26.313228Z","iopub.status.idle":"2022-07-20T02:51:26.938568Z","shell.execute_reply.started":"2022-07-20T02:51:26.313184Z","shell.execute_reply":"2022-07-20T02:51:26.937682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set_style('darkgrid')\ng = sns.FacetGrid(df_train,hue=\"Transported\",palette='viridis',height=6,aspect=2)\ng = g.map(plt.hist,'Age',bins=20,alpha=0.5)\nplt.legend(labels=['Not Transported','Transported'])","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:26.940061Z","iopub.execute_input":"2022-07-20T02:51:26.940589Z","iopub.status.idle":"2022-07-20T02:51:27.451736Z","shell.execute_reply.started":"2022-07-20T02:51:26.940555Z","shell.execute_reply":"2022-07-20T02:51:27.450587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_cnt = df_train['CryoSleep'].count()\nplt.figure(figsize=(10,6))\nlabels = ['Not Transported','Transported']\nsns.set(font_scale = 1)\nsns.set_style(\"white\")\nax = sns.countplot(data=df_train, x='CryoSleep',hue='Transported',palette='viridis')\n#for p in ax.patches:\n#    x, height, width = p.get_x(), p.get_height(), p.get_width()\n#    ax.text(x + width / 2, height + 10, f'{height} / {height / total_cnt * 100:2.1f}%', va='center', ha='center', size=20)\nplt.legend(labels=labels)\nsns.despine()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:27.453856Z","iopub.execute_input":"2022-07-20T02:51:27.454233Z","iopub.status.idle":"2022-07-20T02:51:27.693449Z","shell.execute_reply.started":"2022-07-20T02:51:27.454191Z","shell.execute_reply":"2022-07-20T02:51:27.692212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_cnt = df_train['HomePlanet'].count()\nplt.figure(figsize=(10,6))\nlabels = ['Not Transported','Transported']\nsns.set(font_scale = 1)\nsns.set_style(\"white\")\nax = sns.countplot(data=df_train, x='HomePlanet',hue='Transported',palette='viridis')\n#for p in ax.patches:\n#    x, height, width = p.get_x(), p.get_height(), p.get_width()\n#    ax.text(x + width / 2, height + 10, f'{height} / {height / total_cnt * 100:2.1f}%', va='center', ha='center', size=20)\nplt.legend(labels=labels)\nsns.despine()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:27.908654Z","iopub.execute_input":"2022-07-20T02:51:27.909068Z","iopub.status.idle":"2022-07-20T02:51:28.135664Z","shell.execute_reply.started":"2022-07-20T02:51:27.909031Z","shell.execute_reply":"2022-07-20T02:51:28.134558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_cnt = df_train['VIP'].count()\nplt.figure(figsize=(10,6))\nlabels = ['Not Transported','Transported']\nsns.set(font_scale = 1)\nsns.set_style(\"white\")\nax = sns.countplot(data=df_train, x='VIP',hue='Transported',palette='viridis')\nfor p in ax.patches:\n    x, height, width = p.get_x(), p.get_height(), p.get_width()\n    ax.text(x + width / 2, height + 10, f'{height} / {height / total_cnt * 100:2.1f}%', va='center', ha='center', size=16)\nplt.legend(labels=labels)\nsns.despine()\nplt.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:28.607571Z","iopub.execute_input":"2022-07-20T02:51:28.607985Z","iopub.status.idle":"2022-07-20T02:51:28.899322Z","shell.execute_reply.started":"2022-07-20T02:51:28.607948Z","shell.execute_reply":"2022-07-20T02:51:28.898170Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train['Destination'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:28.915318Z","iopub.execute_input":"2022-07-20T02:51:28.915881Z","iopub.status.idle":"2022-07-20T02:51:28.925185Z","shell.execute_reply.started":"2022-07-20T02:51:28.915848Z","shell.execute_reply":"2022-07-20T02:51:28.924043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"total_cnt = df_train['Destination'].count()\nplt.figure(figsize=(10,6))\nlabels = ['Not Transported','Transported']\nsns.set(font_scale = 1)\nsns.set_style(\"white\")\nax = sns.countplot(data=df_train, x='Destination',hue='Transported',palette='viridis')\nfor p in ax.patches:\n    x, height, width = p.get_x(), p.get_height(), p.get_width()\n    ax.text(x + width / 2, height + 10, f'{height} / {height / total_cnt * 100:2.1f}%', va='center', ha='center', size=14)\nplt.legend(labels=labels)\nsns.despine()\nplt.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:29.213029Z","iopub.execute_input":"2022-07-20T02:51:29.213445Z","iopub.status.idle":"2022-07-20T02:51:29.494124Z","shell.execute_reply.started":"2022-07-20T02:51:29.213407Z","shell.execute_reply":"2022-07-20T02:51:29.492912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"passenger_Id_train=df_train['PassengerId']\npassenger_Id_test=df_test['PassengerId']","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:29.496588Z","iopub.execute_input":"2022-07-20T02:51:29.498310Z","iopub.status.idle":"2022-07-20T02:51:29.503614Z","shell.execute_reply.started":"2022-07-20T02:51:29.498265Z","shell.execute_reply":"2022-07-20T02:51:29.502466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"idCol = df_test.PassengerId.to_numpy()\ndf_train.set_index('PassengerId', inplace=True)\ndf_test.set_index('PassengerId', inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:29.528836Z","iopub.execute_input":"2022-07-20T02:51:29.529799Z","iopub.status.idle":"2022-07-20T02:51:29.537205Z","shell.execute_reply.started":"2022-07-20T02:51:29.529748Z","shell.execute_reply":"2022-07-20T02:51:29.536329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.impute import SimpleImputer\nimputer = SimpleImputer(missing_values=np.nan, strategy='most_frequent')\ndf_train = pd.DataFrame(imputer.fit_transform(df_train), columns=df_train.columns, index=df_train.index)\ndf_test = pd.DataFrame(imputer.fit_transform(df_test), columns=df_test.columns, index=df_test.index)\ndf_train = df_train.reset_index(drop=True)\ndf_test = df_test.reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:51:29.590277Z","iopub.execute_input":"2022-07-20T02:51:29.591222Z","iopub.status.idle":"2022-07-20T02:51:29.677038Z","shell.execute_reply.started":"2022-07-20T02:51:29.591182Z","shell.execute_reply":"2022-07-20T02:51:29.675838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:52:04.532939Z","iopub.execute_input":"2022-07-20T02:52:04.533893Z","iopub.status.idle":"2022-07-20T02:52:04.554432Z","shell.execute_reply.started":"2022-07-20T02:52:04.533851Z","shell.execute_reply":"2022-07-20T02:52:04.553354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train=df_train.drop(['Cabin','Name'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:52:14.137267Z","iopub.execute_input":"2022-07-20T02:52:14.137683Z","iopub.status.idle":"2022-07-20T02:52:14.145286Z","shell.execute_reply.started":"2022-07-20T02:52:14.137646Z","shell.execute_reply":"2022-07-20T02:52:14.144399Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test=df_test.drop(['Cabin','Name'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:52:17.338020Z","iopub.execute_input":"2022-07-20T02:52:17.338702Z","iopub.status.idle":"2022-07-20T02:52:17.345341Z","shell.execute_reply.started":"2022-07-20T02:52:17.338651Z","shell.execute_reply":"2022-07-20T02:52:17.344425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"Age\"] = df_train.Age.astype(float)\ndf_train[\"RoomService\"] = df_train.RoomService.astype(float)\ndf_train[\"FoodCourt\"] = df_train.FoodCourt.astype(float)\ndf_train[\"ShoppingMall\"] = df_train.ShoppingMall.astype(float)\ndf_train[\"Spa\"] = df_train.Spa.astype(float)\ndf_train[\"VRDeck\"] = df_train.VRDeck.astype(float)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:55:48.530507Z","iopub.execute_input":"2022-07-20T02:55:48.530909Z","iopub.status.idle":"2022-07-20T02:55:48.549119Z","shell.execute_reply.started":"2022-07-20T02:55:48.530873Z","shell.execute_reply":"2022-07-20T02:55:48.548221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test[\"Age\"] = df_test.Age.astype(float)\ndf_test[\"RoomService\"] = df_test.RoomService.astype(float)\ndf_test[\"FoodCourt\"] = df_test.FoodCourt.astype(float)\ndf_test[\"ShoppingMall\"] = df_test.ShoppingMall.astype(float)\ndf_test[\"Spa\"] = df_test.Spa.astype(float)\ndf_test[\"VRDeck\"] = df_test.VRDeck.astype(float)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:56:40.576142Z","iopub.execute_input":"2022-07-20T02:56:40.576899Z","iopub.status.idle":"2022-07-20T02:56:40.589255Z","shell.execute_reply.started":"2022-07-20T02:56:40.576859Z","shell.execute_reply":"2022-07-20T02:56:40.588461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:56:06.906290Z","iopub.execute_input":"2022-07-20T02:56:06.906887Z","iopub.status.idle":"2022-07-20T02:56:06.924982Z","shell.execute_reply.started":"2022-07-20T02:56:06.906852Z","shell.execute_reply":"2022-07-20T02:56:06.924170Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.get_dummies(df_train,drop_first=True)\ndf_test = pd.get_dummies(df_test,drop_first=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:56:47.357892Z","iopub.execute_input":"2022-07-20T02:56:47.358674Z","iopub.status.idle":"2022-07-20T02:56:47.385592Z","shell.execute_reply.started":"2022-07-20T02:56:47.358629Z","shell.execute_reply":"2022-07-20T02:56:47.384616Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:56:49.909588Z","iopub.execute_input":"2022-07-20T02:56:49.911959Z","iopub.status.idle":"2022-07-20T02:56:49.931463Z","shell.execute_reply.started":"2022-07-20T02:56:49.911915Z","shell.execute_reply":"2022-07-20T02:56:49.930462Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:56:55.721640Z","iopub.execute_input":"2022-07-20T02:56:55.722724Z","iopub.status.idle":"2022-07-20T02:56:55.742215Z","shell.execute_reply.started":"2022-07-20T02:56:55.722675Z","shell.execute_reply":"2022-07-20T02:56:55.740942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df_train.drop('Transported_True',axis=1)\ny = df_train.pop('Transported_True')","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:57:21.748035Z","iopub.execute_input":"2022-07-20T02:57:21.748779Z","iopub.status.idle":"2022-07-20T02:57:21.756532Z","shell.execute_reply.started":"2022-07-20T02:57:21.748732Z","shell.execute_reply":"2022-07-20T02:57:21.755391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"all_cols = [cname for cname in X.columns]\nprint(all_cols)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:57:24.270686Z","iopub.execute_input":"2022-07-20T02:57:24.271613Z","iopub.status.idle":"2022-07-20T02:57:24.276741Z","shell.execute_reply.started":"2022-07-20T02:57:24.271575Z","shell.execute_reply":"2022-07-20T02:57:24.275923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.preprocessing import StandardScaler","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:57:27.751252Z","iopub.execute_input":"2022-07-20T02:57:27.751909Z","iopub.status.idle":"2022-07-20T02:57:27.756967Z","shell.execute_reply.started":"2022-07-20T02:57:27.751870Z","shell.execute_reply":"2022-07-20T02:57:27.756166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=101)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:00:58.624435Z","iopub.execute_input":"2022-07-20T03:00:58.624830Z","iopub.status.idle":"2022-07-20T03:00:58.632811Z","shell.execute_reply.started":"2022-07-20T03:00:58.624797Z","shell.execute_reply":"2022-07-20T03:00:58.631966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:00:01.237150Z","iopub.execute_input":"2022-07-20T03:00:01.237551Z","iopub.status.idle":"2022-07-20T03:00:01.263946Z","shell.execute_reply.started":"2022-07-20T03:00:01.237516Z","shell.execute_reply":"2022-07-20T03:00:01.263172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"logmodel = LogisticRegression()\nlogmodel.fit(X_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:01:02.114757Z","iopub.execute_input":"2022-07-20T03:01:02.115666Z","iopub.status.idle":"2022-07-20T03:01:02.244511Z","shell.execute_reply.started":"2022-07-20T03:01:02.115615Z","shell.execute_reply":"2022-07-20T03:01:02.243330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = logmodel.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:01:02.958050Z","iopub.execute_input":"2022-07-20T03:01:02.958465Z","iopub.status.idle":"2022-07-20T03:01:02.967252Z","shell.execute_reply.started":"2022-07-20T03:01:02.958432Z","shell.execute_reply":"2022-07-20T03:01:02.965991Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix,classification_report","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:01:03.805060Z","iopub.execute_input":"2022-07-20T03:01:03.805496Z","iopub.status.idle":"2022-07-20T03:01:03.810409Z","shell.execute_reply.started":"2022-07-20T03:01:03.805460Z","shell.execute_reply":"2022-07-20T03:01:03.809284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"confusion_matrix(y_test,preds)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:01:04.652692Z","iopub.execute_input":"2022-07-20T03:01:04.653115Z","iopub.status.idle":"2022-07-20T03:01:04.661570Z","shell.execute_reply.started":"2022-07-20T03:01:04.653058Z","shell.execute_reply":"2022-07-20T03:01:04.660628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(classification_report(y_test,preds))","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:01:05.959817Z","iopub.execute_input":"2022-07-20T03:01:05.960874Z","iopub.status.idle":"2022-07-20T03:01:05.976766Z","shell.execute_reply.started":"2022-07-20T03:01:05.960832Z","shell.execute_reply":"2022-07-20T03:01:05.975495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = logmodel.predict(df_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:01:15.628398Z","iopub.execute_input":"2022-07-20T03:01:15.628812Z","iopub.status.idle":"2022-07-20T03:01:15.641741Z","shell.execute_reply.started":"2022-07-20T03:01:15.628775Z","shell.execute_reply":"2022-07-20T03:01:15.640305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission = pd.DataFrame({'PassengerId': passenger_Id_test, 'Transported': predictions})\n# you could use any filename. We choose submission here\nmy_submission.to_csv('submission_1.csv', index=False)\nmy_submission","metadata":{"execution":{"iopub.status.busy":"2022-07-20T03:06:29.028345Z","iopub.execute_input":"2022-07-20T03:06:29.028788Z","iopub.status.idle":"2022-07-20T03:06:29.053582Z","shell.execute_reply.started":"2022-07-20T03:06:29.028753Z","shell.execute_reply":"2022-07-20T03:06:29.052434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"2","metadata":{"execution":{"iopub.status.busy":"2022-07-20T02:47:33.092369Z","iopub.status.idle":"2022-07-20T02:47:33.092771Z","shell.execute_reply.started":"2022-07-20T02:47:33.092562Z","shell.execute_reply":"2022-07-20T02:47:33.092578Z"},"trusted":true},"execution_count":null,"outputs":[]}]}